DeadSix27 / waifu2x-converter-cpp

Improved fork of Waifu2X C++ using OpenCL and OpenCV
MIT License
792 stars 86 forks source link

building tutorials cannot work on Mac OS Catalina 10.15 #204

Open RoyShen12 opened 5 years ago

RoyShen12 commented 5 years ago

building on Mac OS 10.15 while running "make -j4", following error happens

[ 89%] Linking CXX shared library libw2xc.dylib ld: library not found for -lstdc++fs clang-9: error: linker command failed with exit code 1 (use -v to see invocation)

after comment the line#77 'set(FILE_SYSTEM_LIB "c++fs")' and delete 'c++fs' on the line#365 'target_link_libraries(w2xc ${OPENCV_LIBRARIES} ${CMAKE_DL_LIBS} pthread c++ c++fs)', I found the build is successful

fraemos commented 5 years ago

Same issue on Mac OS 10.14.6

DeadSix27 commented 5 years ago

See https://github.com/DeadSix27/waifu2x-converter-cpp/pull/207#issuecomment-555483400

fraemos commented 5 years ago

I tried this solution. Here is what i got

MacBook-Pro-Maksim:waifu2x-converter-cpp maks-macbook$ make -j4
Scanning dependencies of target conv
[ 14%] Building C object CMakeFiles/conv.dir/conv.c.o
[ 14%] Linking C executable conv
[ 14%] Built target conv
[ 14%] Generating modelHandler_OpenCL.cl.h
[ 14%] Generating modelHandler_CUDA.ptx30.h
[ 14%] Built target gensrcs
Scanning dependencies of target w2xc
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_fma.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_avx.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_sse.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_OpenCL.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/convertRoutine.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/threadPool.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_CUDA.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/w2xconv.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/common.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/cvwrap.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/Env.cpp.o
[ 14%] Building CXX object CMakeFiles/w2xc.dir/src/Buffer.cpp.o
[ 14%] Linking CXX shared library libw2xc.dylib
[ 14%] Built target w2xc
Scanning dependencies of target waifu2x-converter-cpp
[ 14%] Building CXX object CMakeFiles/waifu2x-converter-cpp.dir/src/main.cpp.o
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:451:12: error: 
      'is_directory' is unavailable: introduced in macOS 10.15
                if (!fs::is_directory(outputFileName))
                         ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:1685:39: note: 
      'is_directory' has been explicitly marked unavailable here
inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) {
                                      ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:451:25: error: 'path' is
      unavailable: introduced in macOS 10.15
                if (!fs::is_directory(outputFileName))
                                      ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:772:3: note: 'path' has
      been explicitly marked unavailable here
  path(const _Source& __src, format = format::auto_format) {
  ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:451:25: error: '~path' is
      unavailable: introduced in macOS 10.15
                if (!fs::is_directory(outputFileName))
                                      ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:790:3: note: '~path' has
      been explicitly marked unavailable here
  ~path() = default;
  ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:453:8: error: 
      'create_directories' is unavailable: introduced in macOS 10.15
                        fs::create_directories(outputFileName);
                            ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:1545:39: note: 
      'create_directories' has been explicitly marked unavailable here
inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) {
                                      ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:453:27: error: 'path' is
      unavailable: introduced in macOS 10.15
                        fs::create_directories(outputFileName);
                                               ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:772:3: note: 'path' has
      been explicitly marked unavailable here
  path(const _Source& __src, format = format::auto_format) {
  ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:453:27: error: '~path' is
      unavailable: introduced in macOS 10.15
                        fs::create_directories(outputFileName);
                                               ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:790:3: note: '~path' has
      been explicitly marked unavailable here
  ~path() = default;
  ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:484:74: warning: '&&'
      within '||' [-Wlogical-op-parentheses]
  ...|| lastSlashPos != _tstring::npos && lastDotPos < lastSlashPos)
     ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:484:74: note: place
      parentheses around the '&&' expression to silence this warning
  ...|| lastSlashPos != _tstring::npos && lastDotPos < lastSlashPos)
                                       ^
        (                                                          )
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:501:38: error: 'path' is
      unavailable: introduced in macOS 10.15
void convert_file(ConvInfo info, fs::path inputName, fs::path output)
                                     ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:738:24: note: 'path' has
      been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:501:58: error: 'path' is
      unavailable: introduced in macOS 10.15
void convert_file(ConvInfo info, fs::path inputName, fs::path output)
                                                         ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:738:24: note: 'path' has
      been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:505:68: error: 
      'absolute' is unavailable: introduced in macOS 10.15
        _tstring outputName = generate_output_location(info.origPath, fs::absolu...
                                                                          ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:1474:39: note: 'absolute'
      has been explicitly marked unavailable here
inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) {
                                      ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:505:64: error: '~path' is
      unavailable: introduced in macOS 10.15
        _tstring outputName = generate_output_location(info.origPath, fs::absolu...
                                                                      ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:790:3: note: '~path' has
      been explicitly marked unavailable here
  ~path() = default;
  ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:505:88: error: 'string'
      is unavailable: introduced in macOS 10.15
  ...= generate_output_location(info.origPath, fs::absolute(inputName).TSTRIN...
                                                                       ^
/Users/maks-macbook/waifu2x-converter-cpp/src/tstring.hpp:41:25: note: expanded
      from macro 'TSTRING_METHOD'
        #define TSTRING_METHOD  string
                                ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:998:41: note: 'string' has
      been explicitly marked unavailable here
  _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; }
                                        ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:505:113: error: 'string'
      is unavailable: introduced in macOS 10.15
  ...fs::absolute(inputName).TSTRING_METHOD(), output.TSTRING_METHOD(), info....
                                                      ^
/Users/maks-macbook/waifu2x-converter-cpp/src/tstring.hpp:41:25: note: expanded
      from macro 'TSTRING_METHOD'
        #define TSTRING_METHOD  string
                                ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:998:41: note: 'string' has
      been explicitly marked unavailable here
  _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; }
                                        ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:521:8: error: 'absolute'
      is unavailable: introduced in macOS 10.15
                        fs::absolute(inputName).TSTRING_METHOD().c_str(),
                            ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:1474:39: note: 'absolute'
      has been explicitly marked unavailable here
inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) {
                                      ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:521:4: error: '~path' is
      unavailable: introduced in macOS 10.15
                        fs::absolute(inputName).TSTRING_METHOD().c_str(),
                        ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:790:3: note: '~path' has
      been explicitly marked unavailable here
  ~path() = default;
  ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:521:28: error: 'string'
      is unavailable: introduced in macOS 10.15
                        fs::absolute(inputName).TSTRING_METHOD().c_str(),
                                                ^
/Users/maks-macbook/waifu2x-converter-cpp/src/tstring.hpp:41:25: note: expanded
      from macro 'TSTRING_METHOD'
        #define TSTRING_METHOD  string
                                ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:998:41: note: 'string' has
      been explicitly marked unavailable here
  _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; }
                                        ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:837:6: error: 'path' is
      unavailable: introduced in macOS 10.15
        fs::path input = cmdInput.getValue();
            ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:738:24: note: 'path' has
      been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:837:11: error: 'path' is
      unavailable: introduced in macOS 10.15
        fs::path input = cmdInput.getValue();
                 ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:772:3: note: 'path' has
      been explicitly marked unavailable here
  path(const _Source& __src, format = format::auto_format) {
  ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:837:19: error: '~path' is
      unavailable: introduced in macOS 10.15
        fs::path input = cmdInput.getValue();
                         ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:790:3: note: '~path' has
      been explicitly marked unavailable here
  ~path() = default;
  ^
/Users/maks-macbook/waifu2x-converter-cpp/src/main.cpp:837:11: error: '~path' is
      unavailable: introduced in macOS 10.15
        fs::path input = cmdInput.getValue();
                 ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:790:3: note: '~path' has
      been explicitly marked unavailable here
  ~path() = default;
  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make[2]: *** [CMakeFiles/waifu2x-converter-cpp.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/waifu2x-converter-cpp.dir/all] Error 2
make: *** [all] Error 2
DeadSix27 commented 5 years ago

@fraemos is_directory' is unavailable: introduced in macOS 10.15

Your issue might not actually be related to the original issue as you're actually on 10.14 i just noticed.

It might be that the paths set in cmake are not where you have your libc++fs.a file.

Search for it on your system Cmake looks for it in: /usr/local/opt/llvm/lib and can't find it, that should give you a starting point. Maybe you have something like /usr/local/opt/llvm8/lib or so.

I never worked with apple software/hw so I'm just guessing.

fraemos commented 5 years ago

Thanks for your reply. Finally it worked. Here is what helped me for Mac OS 10.14.6.

  1. Install llvm@8 - brew install llvm@8
  2. Make some changes to the file CMakeLists.txt

    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index 1668437..6244836 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -70,10 +70,10 @@ message(STATUS "System is: ${CMAKE_SYSTEM_NAME} (${LOCAL_SYS_TYPE})")
    
    ### Get binary paths for APPLE users
    if(APPLE)
    -   set(CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang")
    -   set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++")
    -   set(CMAKE_EXE_LINKER_FLAGS "-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib")
    -   set(CMAKE_SHARED_LINKER_FLAGS "-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib")
    +   set(CMAKE_C_COMPILER "/usr/local/opt/llvm@8/bin/clang")
    +   set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm@8/bin/clang++")
    +   set(CMAKE_EXE_LINKER_FLAGS "-L/usr/local/opt/llvm@8/lib -Wl,-rpath,/usr/local/opt/llvm@8/lib")
    +   set(CMAKE_SHARED_LINKER_FLAGS "-L/usr/local/opt/llvm@8/lib -Wl,-rpath,/usr/local/opt/llvm@8/lib")
    set(FILE_SYSTEM_LIB "c++fs")
    elseif(UNIX OR MINGW)
    set(FILE_SYSTEM_LIB "stdc++fs")