无法在MacOS Catalina 10.15下编译c ++应用程序

时间:2019-10-23 14:06:33

标签: c++ cmake clang macos-catalina

注意:有关我如何解决此问题的信息,请查看帖子结尾。

昨天,我已经更新到MacOS Catalina 10.15,从那时起,我一直在尝试编译this c ++应用程序(nori教育射线跟踪器的分支),但是由于某些原因CMake无法找到 pthread 库。这是运行CMake之后的输出:

$ cmake ..
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- 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
-- Setting build type to 'Release' as none was specified.
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Success
-- Performing Test HAS_CPP11_FLAG
-- Performing Test HAS_CPP11_FLAG - Success
-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.11")
-- Performing Test HAVE_GCC_INLINE_ASM_AVX
-- Performing Test HAVE_GCC_INLINE_ASM_AVX - Failed
-- Performing Test HAVE_SYSCONF_NPROCESSORS_ONLN
-- Performing Test HAVE_SYSCONF_NPROCESSORS_ONLN - Failed
-- TBB: NOT using libc++.
-- Looking for pthread.h
-- Looking for pthread.h - not found
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /Applications/CMake.app/Contents/share/cmake-3.15/Modules/FindThreads.cmake:220 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  ext/nanogui/ext/glfw/CMakeLists.txt:60 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/harry/dev/nori/build/CMakeFiles/CMakeOutput.log".
See also "/Users/harry/dev/nori/build/CMakeFiles/CMakeError.log".

然后是CMakeError.log

Performing C++ SOURCE FILE Test HAVE_GCC_INLINE_ASM_AVX failed with the following output:
Change Dir: /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_1e411/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_1e411.dir/build.make CMakeFiles/cmTC_1e411.dir/build
Building CXX object CMakeFiles/cmTC_1e411.dir/src.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -std=c++14 -fvisibility=hidden -Wno-switch -Wno-tautological-compare -Wno-deprecated-register -DHAVE_GCC_INLINE_ASM_AVX -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk -mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk   -o CMakeFiles/cmTC_1e411.dir/src.cxx.o -c /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp/src.cxx
clang: error: invalid version number in '-mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk'
clang: warning: using sysroot for 'DriverKit' but targeting 'MacOSX' [-Wincompatible-sysroot]
make[1]: *** [CMakeFiles/cmTC_1e411.dir/src.cxx.o] Error 1
make: *** [cmTC_1e411/fast] Error 2


Source file was:

    int main()
    {
     #if defined(__GNUC__) && defined(__SSE2__)
         int n   = 0;
         int eax = 0;
         int edx = 0;
         __asm__(
             "xgetbv     ;"
             "vzeroupper  "
             : "=a"(eax), "=d"(edx) : "c"(n) : );
     #else
         #error No GCC style inline asm supported for AVX instructions
     #endif
    }

Performing C++ SOURCE FILE Test HAVE_SYSCONF_NPROCESSORS_ONLN failed with the following output:
Change Dir: /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_db06f/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_db06f.dir/build.make CMakeFiles/cmTC_db06f.dir/build
Building CXX object CMakeFiles/cmTC_db06f.dir/src.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -std=c++14 -fvisibility=hidden -Wno-switch -Wno-tautological-compare -Wno-deprecated-register -DHAVE_SYSCONF_NPROCESSORS_ONLN -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk -mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk   -o CMakeFiles/cmTC_db06f.dir/src.cxx.o -c /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp/src.cxx
clang: error: invalid version number in '-mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk'
clang: warning: using sysroot for 'DriverKit' but targeting 'MacOSX' [-Wincompatible-sysroot]
make[1]: *** [CMakeFiles/cmTC_db06f.dir/src.cxx.o] Error 1
make: *** [cmTC_db06f/fast] Error 2


Source file was:

    #include <unistd.h>
    int main()
    {
        sysconf(_SC_NPROCESSORS_ONLN);
    }

Performing C++ SOURCE FILE Test HAS_LIBCPP failed with the following output:
Change Dir: /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_4098b/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_4098b.dir/build.make CMakeFiles/cmTC_4098b.dir/build
Building CXX object CMakeFiles/cmTC_4098b.dir/src.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -std=c++14 -fvisibility=hidden -DHAS_LIBCPP -stdlib=libc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk -mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk   -o CMakeFiles/cmTC_4098b.dir/src.cxx.o -c /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp/src.cxx
clang: error: invalid version number in '-mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk'
clang: warning: using sysroot for 'DriverKit' but targeting 'MacOSX' [-Wincompatible-sysroot]
clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
make[1]: *** [CMakeFiles/cmTC_4098b.dir/src.cxx.o] Error 1
make: *** [cmTC_4098b/fast] Error 2


...and run output:

Return value: 1
Source file was:
#include <iostream>
int main(int argc, char **argv) { std::cout << "test"; return 0; }
Performing C++ SOURCE FILE Test SUPPORTS_STDCXX11 failed with the following output:
Change Dir: /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_74f47/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_74f47.dir/build.make CMakeFiles/cmTC_74f47.dir/build
Building CXX object CMakeFiles/cmTC_74f47.dir/src.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -std=c++14 -fvisibility=hidden -DSUPPORTS_STDCXX11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk -mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk   -std=c++11 -o CMakeFiles/cmTC_74f47.dir/src.cxx.o -c /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp/src.cxx
clang: error: invalid version number in '-mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk'
clang: warning: using sysroot for 'DriverKit' but targeting 'MacOSX' [-Wincompatible-sysroot]
make[1]: *** [CMakeFiles/cmTC_74f47.dir/src.cxx.o] Error 1
make: *** [cmTC_74f47/fast] Error 2


Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test SUPPORTS_MRTM failed with the following output:
Change Dir: /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_60b35/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_60b35.dir/build.make CMakeFiles/cmTC_60b35.dir/build
Building CXX object CMakeFiles/cmTC_60b35.dir/src.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -std=c++14 -fvisibility=hidden -DSUPPORTS_MRTM -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk -mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk   -mrtm -Werror -o CMakeFiles/cmTC_60b35.dir/src.cxx.o -c /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp/src.cxx
clang: error: invalid version number in '-mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk'
clang: error: using sysroot for 'DriverKit' but targeting 'MacOSX' [-Werror,-Wincompatible-sysroot]
make[1]: *** [CMakeFiles/cmTC_60b35.dir/src.cxx.o] Error 1
make: *** [cmTC_60b35/fast] Error 2


Source file was:
int main() { return 0; }
Determining if the include file pthread.h exists failed with the following output:
Change Dir: /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_b4d5d/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_b4d5d.dir/build.make CMakeFiles/cmTC_b4d5d.dir/build
Building C object CMakeFiles/cmTC_b4d5d.dir/CheckIncludeFile.c.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc   -Wno-deprecated-declarations  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk -mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk   -o CMakeFiles/cmTC_b4d5d.dir/CheckIncludeFile.c.o   -c /Users/harry/dev/nori/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
clang: error: invalid version number in '-mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk'
clang: warning: using sysroot for 'DriverKit' but targeting 'MacOSX' [-Wincompatible-sysroot]
make[1]: *** [CMakeFiles/cmTC_b4d5d.dir/CheckIncludeFile.c.o] Error 1
make: *** [cmTC_b4d5d/fast] Error 2

nori ray跟踪程序需要XCode以及MacOS计算机上安装的命令行工具。我有Xcode版本11.1和相应的命令行工具。

据我从CMakeError.log文件中看到,由于 mmacosx-version-min 的无效版本号,clang产生了一个错误。

clang: error: invalid version number in '-mmacosx-version-min=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/DriverKit19.0.sdk'

我已经研究了一段时间,试图找到有关该主题的线索,但未能找到解决我问题的方法。我拥有的clang版本是随Xcode安装的版本:Apple clang version 11.0.0

我愿意听取任何建议,并提供有关我的配置的任何其他信息,您可能会发现这对于查明问题很有帮助。


P.S。:我忘了提到,当我第一次开始从事该项目时,在MacOS Mojave here上也遇到了类似的问题。而且我能够通过安装this post中所述的SDK标头来对其进行修复:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

有效的解决方案: :安装较旧版本的XCode(10.2.1对我来说很有效)并重定向到它(使用{{1 }})可以解决我的问题。该解决方案由GitHub的Aaron19960821提出。参见here

0 个答案:

没有答案