DeadSix27 / waifu2x-converter-cpp

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

Compile fail on macOS Catalina 10.15.6 - no namespace std::filesystem #251

Closed thefrostysnowman closed 3 years ago

thefrostysnowman commented 4 years ago

After following the Mac build steps, make is failing with the following:

.../waifu2x-converter-cpp/src/modelHandler_OpenCL.cpp:54:16: error: no namespace named 'filesystem' in namespace 'std'; did you mean std::__fs::filesystem'?
namespace fs = std::filesystem;
               ^~~~~~~~~~~~~~~
               std::__fs::filesystem
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:259:1: note: namespace 'std::__fs::filesystem' defined here
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
^
/usr/local/opt/llvm/bin/../include/c++/v1/__config:790:58: note: expanded from macro '_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM'
  _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
                                                         ^

By commenting out the offending line the build succeeded and Waifu2x works as expected. It appears the fs definition can be defined out for Mac?

Make specified this information about my machine:

-- Found git, set version to: v5.3.3 (master-e7de04d)
-- System is: Darwin (Apple)
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.
-- 
-- Config summary:
--  OpenCV: 4.4.0
--  OpenCL: 1.2
--  CUDA: Not found
--  Unicode: TRUE
--  Installing models to: /usr/local/share/waifu2x-converter-cpp
--  Not building test binaries
--  Building for: Unix Makefiles-x86_64
EpLiar commented 4 years ago

Try to modify this part: (It works on my Mac.)

54c54
< namespace fs = std::filesystem;
---
> namespace fs = std::__fs::filesystem;
EpLiar commented 4 years ago

Try to modify this part: (It works on my Mac.)

54c54
< namespace fs = std::filesystem;
---
> namespace fs = std::__fs::filesystem;

On https://github.com/DeadSix27/waifu2x-converter-cpp/blob/master/src/modelHandler_OpenCL.cpp

thefrostysnowman commented 4 years ago

Do you know if the std::__fs::filesystem namespace is available on all the platforms that currently successfully use std::filesystem? That's a clean solution if so.

I made a commit for my own use which skips the fs definition entirely if GENERATE_BINARY isn't defined since it isn't used unless GENERATE_BINARY is defined. Unfortunately I don't have any other computers to test my change on, so I can't validate whether this breaks another platform's compile. https://github.com/thefrostysnowman/waifu2x-converter-cpp/commit/96818ae2223d9d9abbf021d3a9d9f9cbd1d457dc

EpLiar commented 4 years ago

Do you know if the std::__fs::filesystem namespace is available on all the platforms that currently successfully use std::filesystem? That's a clean solution if so.

Or write a macro for macOS?

YukihoAA commented 3 years ago

Fixed by PR #255