DeadSix27/waifu2x-converter-cpp

Error when building on OS X 10.12.6

xxprototypexx32 opened this issue · 49 comments

Running OS X Sierra 10.12.6
All goes well until the "make" part, this just happens:
https://pastebin.com/m763EaME
Yes I do have the latest version of openCV installed
I have OpenCV 3.3.0 and Cmake 3.9 installed
The latest versions of both, what's wrong?

Edit 2:
I somehow managed to solve some of these problems and now I get this
https://pastebin.com/G0Nxrgbw
Though I think you should still look at the first log in case anyone else has the same problem and also because I may have done stuff wrongly

Which compiler are you using? Is it capable of c++ 17? Is it using the latest version?

"/Users/eujingoh/waifu2x-converter-cpp/src/main.cpp:20:10: fatal error: 'experimental/filesystem' file not found"
Could you try to compile it without "experimental/" and without "::experimental" in main.cpp ?

If you just want it to work, you can but without the changes I PR'ed into it. Just get the version prior to me doing so.
https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset

Using this sha1 d693130 or d69313040b0784662465fb1d2eca81a2b1ebccb2

I'm using xcode which currently doesn't have support
I then used GCC but then the Waifu2x executable didn't appear

I tried the v4 release instead and it worked so there's that

I then used GCC but then the Waifu2x executable didn't appear

Did it give you any useful logs? If so could you send them to me.

Oh, and could you also send the result of this gcc -v

I'm not currently at home so, you'll have to wait a while and, the only logs I got was what was built

I also need to say I know nothing about programming

this is all gcc -v gives

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

and this is the "log" when building from gcc

Scanning dependencies of target conv
[ 5%] Building C object CMakeFiles/conv.dir/conv.c.o
[ 10%] Linking C executable conv
[ 10%] Built target conv
Scanning dependencies of target gensrcs
[ 15%] Generating modelHandler_OpenCL.cl.h
[ 15%] Built target gensrcs
Scanning dependencies of target w2xc
[ 21%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_avx.cpp.o
[ 26%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler.cpp.o
[ 31%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_fma.cpp.o
[ 36%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_sse.cpp.o
[ 47%] Building CXX object CMakeFiles/w2xc.dir/src/convertRoutine.cpp.o
[ 47%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_OpenCL.cpp.o
[ 52%] Building CXX object CMakeFiles/w2xc.dir/src/threadPool.cpp.o
[ 57%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_CUDA.cpp.o
[ 63%] Building CXX object CMakeFiles/w2xc.dir/src/w2xconv.cpp.o
[ 68%] Building CXX object CMakeFiles/w2xc.dir/src/common.cpp.o
[ 73%] Building CXX object CMakeFiles/w2xc.dir/src/cvwrap.cpp.o
[ 78%] Building CXX object CMakeFiles/w2xc.dir/src/Env.cpp.o
[ 84%] Building CXX object CMakeFiles/w2xc.dir/src/Buffer.cpp.o
[ 89%] Linking CXX shared library libw2xc.dylib
[ 89%] Built target w2xc
Scanning dependencies of target runbench
[ 94%] Building C object CMakeFiles/runbench.dir/w32-apps/runbench.c.o
[100%] Linking C executable runbench
[100%] Built target runbench

although I missed some information that I should say

In order to even get to that stage for the current build I had to add
set (CMAKE_CXX_STANDARD 11)

to CMakeLists.txt otherwise I'd get a whole ton of errors and warnings then do cmake followed by make to get the 'experimental/filesystem' not found
then to do make again but with gcc and then do make again
If that's a little hard to read, the command chain would go like this

cmake -DOVERRIDE_OPENCV=1 -DOPENCV_PREFIX=/usr/local/Cellar/opencv/3.3.0_3 .
make -j 4
cmake -DOVERRIDE_OPENCV=1 -DOPENCV_PREFIX=/usr/local/Cellar/opencv/3.3.0_3 . -DCMAKE_C_COMPILER=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/local/Cellar/gcc/7.2.0/bin/g++-7
make -j4

it will complete but waifu2x executable will not be produced
EDIT: If you want the log for that its here
https://pastebin.com/jQFnGPPW

If I were to do cmake from gcc and to make immediately I'd get this
https://pastebin.com/Ki3jPTCJ

As I said I have no knowledge of programming and have close to no idea what I'm doing
And you also need not spend time on this since you've already given me a solution, I don't need the current build to be working that much...

set (CMAKE_CXX_STANDARD 11) it should be set (CMAKE_CXX_STANDARD 17) anyhow, thank you for the help.

toyg commented

Yeah, it looks like it doesn't build anymore on OSX. Switching to gcc seems to break opencv that comes with homebrew. I'll see what I can do.

If anybody reading this wants to help, feel free to step forward.

Did you guys figure out the issue by now?
Did you try compiling before: 28f66dd
and before: a2a6744

To see if those changes made it fail to compile on OSX?

I have to rely on others for OSX, I can't test compilation for it at all (i do not own a apple pc)

(I don't have a mac)
@toyg which compiler are you using? If you're using Xcode it should be atleast version 9.X .
Because my patches require c++ 17, I could rewrite my patches to use boost but using the latest version of the spec is better IMHO.

If I'm not wrong Xcode 9 is still in beta...

Could you try it anyhow? If we can compile using it we should be able to use those binaries on any capable mac device no?

(wow I've been got for a while)
anyway here's the log without
set (CMAKE_CXX_STANDARD 17)
https://pastebin.com/Hwve4Emx
It's pretty much the same as before, at least from what I see
And with it...
https://pastebin.com/fUAfQnpJ
Also the same case, no 'experimental/filesystem', not included in xcode 9 maybe?
And with gcc
The same thing, no 'experimental/filesystem'
It appears apple doesn't like experimental things...

I also don't know what you mean by

Could you try to compile it without "experimental/" and without "::experimental" in main.cpp ?

Do you want me to remove just those specific lines in main.cpp or remove the entire line? So
#include <experimental/filesystem>
v
#include <filesystem>
like this?

It appears apple doesn't like experimental things...

True.

Do you want me to remove just those specific lines in main.cpp or remove the entire line? So

Like you showed in your example, here is what you should do.

#include <experimental/filesystem>

into

#include

and

namespace fs = std::experimental::filesystem;

into

namespace fs = std::filesystem;

toyg commented

With the latest XCode updates, simply by checking out d693130 and without doing any change, it works just fine again.

I tried checking out head and making the changes in #issuecomment-336910126 but that errors out.

@toyg what cmake version does macos use? Should be 3.8 or newer, just curious

toyg commented
cmake version 3.9.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Can you run cmake with cmake .. -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
and show me the full output

toyg commented
cmake -DOVERRIDE_OPENCV=1 -DOPENCV_PREFIX=/usr/local/Cellar/opencv3/ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
-- The C compiler identification is AppleClang 9.0.0.9000038
-- The CXX compiler identification is AppleClang 9.0.0.9000038
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2")
-- Checking for module 'opencv'
--   Found opencv, version 3.3.0
-- Found OpenCV
-- Looking for CL_VERSION_2_0
-- Looking for CL_VERSION_2_0 - not found
-- Looking for CL_VERSION_1_2
-- Looking for CL_VERSION_1_2 - found
-- Found OpenCL: /System/Library/Frameworks/OpenCL.framework (found version "1.2")
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY)
-- CUDA not found. disabled.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/toyg/Dev/waifu2x-dev
toyg commented

Edited by DeadSix (please use pastebin or so in the future):
https://pastebin.com/vZJ4hpEJ

@toyg your cmake can't find opencv, can you make a fully clean sub folder, then run the following:

cmake .. -DOPENCV_PREFIX=/usr/local/Cellar/opencv3/ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON

Then go into CMakeFiles and upload the content of CMakeError.log and CMakeOutput.log on pastebin or so.

About the c++ issues, lets first figure the opencv thing out

@toyg nvm you must have edited/updated your post, I assume you are on the newest version of the repo now?

toyg commented

Yeah i did a clean checkout

@toyg
Can you run sed -i -e 's/emplace_back/push_back/' ./src/*
In the root of the repo before doing anything?
Then run cmake as shown above and then compile

@toyg I wanna test something, in include/picojson.h, see line 47, there it says:

# include <cmath>
Correct?

Change that to: # include <math.h>

@toyg ye I'm clueless.. Can't you get g++ on MacOS or cross compile to apple from linux (altho I do not think the cmake file supports that)?

Ill add help wanted tag.. not that seems to attract many people considering every issue has that tag at this point :p

I think I'm getting somewhere...
I installed the latests version of llvm using homebrew which includes the "experimental filesystem" thing and compiled using that and then it gave the error of missing "cl.h" so I copied the entire headers file from xcode

/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers

into

llvm/include/c++/v1

and renamed the file from "Headers" into "CL"
Now just like before it builds everything except the "waifu2x-converter-cpp"
heres the log:

[  8%] Built target conv
[ 13%] Built target gensrcs
[ 17%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_CUDA.cpp.o
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/w2xconv.cpp.o
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/threadPool.cpp.o
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_OpenCL.cpp.o
[ 34%] Building CXX object CMakeFiles/w2xc.dir/src/common.cpp.o
[ 39%] Building CXX object CMakeFiles/w2xc.dir/src/cvwrap.cpp.o
[ 43%] Building CXX object CMakeFiles/w2xc.dir/src/Env.cpp.o
[ 47%] Building CXX object CMakeFiles/w2xc.dir/src/Buffer.cpp.o
/Users/test/Desktop/waifu2x-converter-cpp-master/src/w2xconv.cpp:411:10: warning: enumeration value
      'W2XCONV_ERROR_OPENCL' not handled in switch [-Wswitch]
        switch (conv->last_error.code) {
                ^
/Users/test/Desktop/waifu2x-converter-cpp-master/src/w2xconv.cpp:441:10: warning: enumeration value
      'W2XCONV_ERROR_OPENCL' not handled in switch [-Wswitch]
        switch (e->code) {
                ^
2 warnings generated.
[ 52%] Linking CXX shared library libw2xc.dylib
[ 73%] Built target w2xc
Scanning dependencies of target runtest
Scanning dependencies of target runbench
Scanning dependencies of target waifu2x-converter-cpp
[ 82%] Building C object CMakeFiles/runbench.dir/w32-apps/runbench.c.o
[ 82%] Building C object CMakeFiles/runtest.dir/w32-apps/runtest.c.o
[ 86%] Building CXX object CMakeFiles/waifu2x-converter-cpp.dir/src/main.cpp.o
[ 91%] Linking C executable runtest
[ 95%] Linking C executable runbench
[ 95%] Built target runtest
[ 95%] Built target runbench
[100%] Linking CXX executable waifu2x-converter-cpp
ld: library not found for -lstdc++fs
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [waifu2x-converter-cpp] Error 1
make[1]: *** [CMakeFiles/waifu2x-converter-cpp.dir/all] Error 2
make: *** [all] Error 2

@xxprototypexx32 Make sure to read "EDIT2" @ above post

EDIT2

gives

Scanning dependencies of target conv
[  4%] Building C object CMakeFiles/conv.dir/conv.c.o
[  8%] Linking C executable conv
[  8%] Built target conv
Scanning dependencies of target gensrcs
[ 13%] Generating modelHandler_OpenCL.cl.h
[ 13%] Built target gensrcs
Scanning dependencies of target w2xc
[ 21%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler.cpp.o
[ 21%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_fma.cpp.o
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_sse.cpp.o
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_avx.cpp.o
[ 34%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_OpenCL.cpp.o
[ 39%] Building CXX object CMakeFiles/w2xc.dir/src/convertRoutine.cpp.o
[ 43%] Building CXX object CMakeFiles/w2xc.dir/src/threadPool.cpp.o
[ 47%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_CUDA.cpp.o
[ 52%] Building CXX object CMakeFiles/w2xc.dir/src/w2xconv.cpp.o
[ 56%] Building CXX object CMakeFiles/w2xc.dir/src/common.cpp.o
[ 60%] Building CXX object CMakeFiles/w2xc.dir/src/cvwrap.cpp.o
[ 65%] Building CXX object CMakeFiles/w2xc.dir/src/Env.cpp.o
/Users/test/Desktop/Waifu2x tests/waifu2x-converter-cpp-cmake_rework/src/w2xconv.cpp:411:10: warning: 
      enumeration value 'W2XCONV_ERROR_OPENCL' not handled in switch [-Wswitch]
        switch (conv->last_error.code) {
                ^
/Users/test/Desktop/Waifu2x tests/waifu2x-converter-cpp-cmake_rework/src/w2xconv.cpp:441:10: warning: 
      enumeration value 'W2XCONV_ERROR_OPENCL' not handled in switch [-Wswitch]
        switch (e->code) {
                ^
[ 69%] Building CXX object CMakeFiles/w2xc.dir/src/Buffer.cpp.o
2 warnings generated.
[ 73%] Linking CXX shared library libw2xc.dylib
ld: library not found for -lstdc++fs
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libw2xc.dylib] Error 1
make[1]: *** [CMakeFiles/w2xc.dir/all] Error 2
make: *** [all] Error 2

removing "stdc++fs" gives
https://pastebin.com/B8qXyuXZ

@xxprototypexx32 Can you try renaming every occurence of "stdc++" to "c++experimental"
in CMakeLists.txt (Like here: https://github.com/DeadSix27/waifu2x-converter-cpp/blob/cmake_rework/CMakeLists.txt#L293)
And if that doesn't work, change it to "stdc++" again and just add "c++experimental" as well (so you have both)

I saw that here: https://stackoverflow.com/a/45332844

I never really touched clang.. so idk what the clang equivalent for experimental::filesystem is and in what library it is.

EDIT: There is also: https://stackoverflow.com/a/46385720 and https://stackoverflow.com/a/42634858

This is the log now

Scanning dependencies of target conv
[  4%] Building C object CMakeFiles/conv.dir/conv.c.o
[  8%] Linking C executable conv
[  8%] Built target conv
Scanning dependencies of target gensrcs
[ 13%] Generating modelHandler_OpenCL.cl.h
[ 13%] Built target gensrcs
Scanning dependencies of target w2xc
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler.cpp.o
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_fma.cpp.o
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_sse.cpp.o
[ 30%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_avx.cpp.o
[ 34%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_OpenCL.cpp.o
[ 39%] Building CXX object CMakeFiles/w2xc.dir/src/convertRoutine.cpp.o
[ 43%] Building CXX object CMakeFiles/w2xc.dir/src/threadPool.cpp.o
[ 47%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_CUDA.cpp.o
[ 52%] Building CXX object CMakeFiles/w2xc.dir/src/w2xconv.cpp.o
[ 56%] Building CXX object CMakeFiles/w2xc.dir/src/common.cpp.o
[ 60%] Building CXX object CMakeFiles/w2xc.dir/src/cvwrap.cpp.o
[ 65%] Building CXX object CMakeFiles/w2xc.dir/src/Env.cpp.o
/Users/test/Desktop/Waifu2x tests/waifu2x-converter-cpp-cmake_rework/src/w2xconv.cpp:411:10: warning: 
      enumeration value 'W2XCONV_ERROR_OPENCL' not handled in switch [-Wswitch]
        switch (conv->last_error.code) {
                ^
/Users/test/Desktop/Waifu2x tests/waifu2x-converter-cpp-cmake_rework/src/w2xconv.cpp:441:10: warning: 
      enumeration value 'W2XCONV_ERROR_OPENCL' not handled in switch [-Wswitch]
        switch (e->code) {
                ^
[ 69%] Building CXX object CMakeFiles/w2xc.dir/src/Buffer.cpp.o
2 warnings generated.
[ 73%] Linking CXX shared library libw2xc.dylib
ld: library not found for -lc++experimentalfs
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libw2xc.dylib] Error 1
make[1]: *** [CMakeFiles/w2xc.dir/all] Error 2
make: *** [all] Error 2

Do I remove the "fs" at the back or leave it there?

Remove c++experimentalfs

Remove c++experimentalfs

Sorry, what? I don't have any experience with coding so pardon me
Also you said

just add "c++experimental"

So do I add it at the back like " stdc++ c++experimental"

Try: "stdc++ c++experimental" if not work then try: "c++experimental"

Alright pretty much the same results...
its just throws
"ld: library not found for"
all three

Wait, even for "stdc++" ? (I mean does it say it can't find that one)

And Idk then, someone with more experience on XCode/Clang etc would need to figure out how to use filesystem there..

Wait, even for "stdc++" ? (I mean does it say it can't find that one)

Didn't the log show that when I posted for

EDIT2:

@xxprototypexx32 Not really, it showed you lack stdc++fs, not stdc++.

(Using just "stdc++" does that work?)

(Using just "stdc++" does that work?)

No, it just shows "Undefined symbols for architecture x86_64"
and a whole bunch of "referenced from:"

Did you build clang with: -DLIBCXX_ENABLE_FILESYSTEM=ON -DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON

See: https://reviews.llvm.org/rL273034

I installed with homebrew, there aren't any options for that
Edit: It's also 1:40 am in my timezone so, I'll be going to sleep now

http://formulae.brew.sh/repos/Homebrew/homebrew-core/formula/gcc

Homebrew has gcc 7.2.0 Why are you not using that?

(or would that be cross compiling? I literally have no idea how this works on apple)

I used gcc on my second post in this thread
Also when I try again now, it gives the undefined symbols for x86_64 architecture or something along those lines

Run again with gcc and use "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" in cmake then post full output of cmake and make

this issue seems like fixed, as you can see #131 , we have no problem building with OSX.