C++ C+的问题+;macOS上的编译器(构建cmake项目)

C++ C+的问题+;macOS上的编译器(构建cmake项目),c++,xcode,macos,C++,Xcode,Macos,我有一个16英寸的MacBook pro,有最新的更新(macOS Catalina 10.15.2(19C57)),最新版本的XCode和macOS命令行工具(这些工具安装在通常的路径/库/开发人员/命令行工具/)。。不确定这是否与我的问题有关,但我的机器上安装了JetBrains的CLion的最新版本(运行时没有问题) 问题出在这里:尝试使用cmake构建项目时,构建失败,并显示以下错误消息: In file included from /Users/basavyr/Pipeline/Dev

我有一个16英寸的MacBook pro,有最新的更新(macOS Catalina 10.15.2(19C57)),最新版本的XCode和macOS命令行工具(这些工具安装在通常的路径/库/开发人员/命令行工具/)。。不确定这是否与我的问题有关,但我的机器上安装了JetBrains的CLion的最新版本(运行时没有问题)

问题出在这里:尝试使用cmake构建项目时,构建失败,并显示以下错误消息:

In file included from /Users/basavyr/Pipeline/DevWorkspace/Github/xrootd/bindings/python/src/PyXRootDFile.cc:25:
In file included from /Users/basavyr/Pipeline/DevWorkspace/Github/xrootd/bindings/python/src/PyXRootD.hh:28:
In file included from /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:38:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string.h:61:15: fatal error: 
      'string.h' file not found
#include_next <string.h>
1 error generated.
error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc' failed with exit status 1
make[2]: *** [bindings/python/python_bindings] Error 1
make[1]: *** [bindings/python/CMakeFiles/python_target.dir/all] Error 2
make: *** [all] Error 2
然后,我尝试了
/Applications/Xcode.app/Contents/Developer/usr/bin/g++main.cpp
,效果很好。 在我的机器上检查“g++”的版本会得到以下信息:

g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
这很有趣,因为我希望默认编译器安装在
/usr/bin/
中。进入“安装”文件夹,我看到没有“g++”二进制,但只有“CLAN+++”和“C++”,所以我尝试用这两个编译,结果证明这两个编译器都和我试图构建的项目中的错误相同:

basavyr@Roberts-MacBook-Pro stringTestCLANG % /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ main.cpp
In file included from main.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:505:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__string:57:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:642:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:61:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string.h:61:15: fatal error: 
      'string.h' file not found
#include_next <string.h>
              ^~~~~~~~~~
1 error generated.
basavyr@Roberts-MacBook-Pro stringTestCLANG %
因此,我假设当我使用cmake构建该项目时,它正在使用这些编译器中的一个(来自XCodeDefault.xctoolchain文件夹),并且它的字符串头有问题

Q1:如何解决此问题Q2:还有,为什么我的“g++”安装目录指向这个XCodeDefault.xToolchain,而不是“/usr/bin/”或“/Applications/Xcode.app/Contents/Developer/usr/bin/”。在macOS中有办法改变这一点吗


提前谢谢你

首先,祝贺你拥有了一台16英寸的MacBook pro。你能检查一下答案吗?这回答了你的问题吗?@OnurTuna谢谢你哈哈!让我看看帖子,我会回复你的。
g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
basavyr@Roberts-MacBook-Pro stringTestCLANG % /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ main.cpp
In file included from main.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:505:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__string:57:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:642:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:61:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string.h:61:15: fatal error: 
      'string.h' file not found
#include_next <string.h>
              ^~~~~~~~~~
1 error generated.
basavyr@Roberts-MacBook-Pro stringTestCLANG %
basavyr@Roberts-MacBook-Pro stringTestCLANG % /Library/Developer/CommandLineTools/usr/bin/c++ main.cpp
In file included from main.cpp:1:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iostream:38:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ios:216:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__locale:15:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:505:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:176:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:642:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found
#include_next <string.h>
              ^~~~~~~~~~
1 error generated.