Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monterey cmake error diary #84

Open
hstdt opened this issue Jan 1, 2022 · 0 comments
Open

Monterey cmake error diary #84

hstdt opened this issue Jan 1, 2022 · 0 comments

Comments

@hstdt
Copy link

hstdt commented Jan 1, 2022

ENV:
M1, macOS Monterey 12.1
Xcode 13.2.1

I know nothing about cmake and qt, but google knows馃惗

  1. error /usr/local/opt/llvm/bin/clang++ is not a full path to an existing compiler tool.

CleanShot 2022-01-02 at 00 07 33

which clang++ ==> /opt/homebrew/opt/llvm/bin/clang++

that means

 cmake -DCMAKE_C_COMPILER="/usr/local/opt/llvm/bin/clang" -DCMAKE_CXX_COMPILER="/usr/local/opt/llvm/bin/clang++" .

should be

cmake -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) .
  1. error Could not find a package configuration file provided by "Qt5" with any of the following names

CleanShot 2022-01-02 at 00 22 52

add -DCMAKE_PREFIX_PATH=$(brew --prefix qt5)

cmake -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_PREFIX_PATH=$(brew --prefix qt5) .
  1. error Failed to find "gl.h" in "/System/Library/Frameworks/OpenGL.framework/Headers;/System/Library/Frameworks/AGL.framework/Headers".

CleanShot 2022-01-02 at 00 48 48

this problem seems related to CMAKE_OSX_SYSROOT, and CMAKE_OSX_SYSROOT directory is not exists(picture 1).

grep -r CMAKE_OSX_SYSROOT == > ./CMakeCache.txt:CMAKE_OSX_SYSROOT:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

but MacOSX10.15.sdk is valid for legacy Xcode.

so modify /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk in ./CMakeCache.txt

  1. error Could NOT find OpenMP

CleanShot 2022-01-02 at 01 10 39

add these code before if(APPLE) in CMakeLists.txt

# https://stackoverflow.com/a/48216682/4728060

set(OPENMP_LIBRARIES "/opt/homebrew/opt/llvm/lib")
set(OPENMP_INCLUDES "/opt/homebrew/opt/llvm/include")

OPTION (USE_OpenMP "Use OpenMP to enamble <omp.h>" ON)

# Find OpenMP
if(APPLE AND USE_OpenMP)
    if(CMAKE_C_COMPILER_ID MATCHES "Clang")
        set(OpenMP_C "${CMAKE_C_COMPILER}")
        set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
        set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
        set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
        set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
        set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
    endif()
    if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
      set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
      set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
      set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
      set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
      set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
      set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
    endif()
endif()

if(USE_OpenMP)
  find_package(OpenMP REQUIRED)
endif(USE_OpenMP)

if (OPENMP_FOUND)
    include_directories("${OPENMP_INCLUDES}")
    link_directories("${OPENMP_LIBRARIES}")
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    # set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif(OPENMP_FOUND)

CleanShot 2022-01-02 at 01 51 33

  1. error CMake Error at GUI/CMakeLists.txt:67 (install): install TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable target "Anime4KCPP_GUI".

https://cmake.org/cmake/help/v3.9/policy/CMP0006.html

add BUNDLE DESTINATION bin in GUI/CMakeLists.txt

CleanShot 2022-01-02 at 01 30 36

  1. error CMake Error in core/CMakeLists.txt: Imported target "OpenCL::OpenCL" includes non-existent path "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenCL.framework"

replace all MacOSX10.15.sdk to MacOSX.sdk in CMakeCache.txt(same as error 3)

  1. error Could NOT find Threads (missing: Threads_FOUND)

find solution here

add code in the beginning of CMakeLists.txt

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

X. finally build done, with an empty app is created馃槀 (tried another times with nothing generated...)

CleanShot 2022-01-02 at 01 49 29

-- Found OpenMP_CXX: -fopenmp=libomp -Wno-unused-command-line-argument  
-- Failed to complie has_filesystem.cpp, will use boost::filesystem instead of std::filesystem
Change Dir: /path/to/Anime4KCPP/tmp/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_a8706/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_a8706.dir/build.make CMakeFiles/cmTC_a8706.dir/build
Building CXX object CMakeFiles/cmTC_a8706.dir/has_filesystem.cpp.o
/opt/homebrew/opt/llvm/bin/clang++   -fopenmp=libomp -Wno-unused-command-line-argument  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -std=c++17 -MD -MT CMakeFiles/cmTC_a8706.dir/has_filesystem.cpp.o -MF CMakeFiles/cmTC_a8706.dir/has_filesystem.cpp.o.d -o CMakeFiles/cmTC_a8706.dir/has_filesystem.cpp.o -c /Users/tdt/Documents/Code/GitHub/Anime4KCPP/cmake/DetectionSample/has_filesystem.cpp
Linking CXX executable cmTC_a8706
/opt/homebrew/Cellar/cmake/3.22.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a8706.dir/link.txt --verbose=1
/opt/homebrew/opt/llvm/bin/clang++  -fopenmp=libomp -Wno-unused-command-line-argument  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_a8706.dir/has_filesystem.cpp.o -o cmTC_a8706 
ld: library not found for -lomp
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_a8706] Error 1
make: *** [cmTC_a8706/fast] Error 2


-- Building information:
   Build date: 2022-01-02

   Build CLI ON
   Build GUI OFF
   Build VapourSynth plugin OFF
   Build AviSynthPlus plugin OFF
   Build C wrapper OFF

   Build static C wrapper OFF
   Build static core ON
   Built-in kernel ON

   Use Boost filesystem ON
   Use Eigen3 OFF
   Use legacy OpenCL API ON

   Ryzen optimization OFF
   Native optimization OFF
   Other optimization for core OFF
   Other optimization for other OFF

   Enable arm neon OFF
   Enable SSE4.2 OFF
   Enable AVX OFF
   Enable AVX2 OFF

   Enable IPO OFF
   Enable OpenCL ON
   Enable CUDA OFF
   Enable NCNN OFF
   Enable OpenCV DNN OFF
   Enable video ON
   Enable preview GUI ON
   Enable image IO ON
   Disable parallel OFF

   Parallel library OpenMP

-- Build type: 

-- C++ compiler flags:
  -fopenmp=libomp -Wno-unused-command-line-argument

-- CLI: libcurl found, enable web image download support.
-- Found OpenMP_CXX: -fopenmp=libomp -Wno-unused-command-line-argument  
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_C_COMPILER


-- Build files have been written to: /path/to/Anime4KCPP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant