更新时间:2022-12-01 08:46:57
我遇到了同样的问题.
我在/Applications/.../MacOSX10.14.sdk/usr/include
中安装了标题.我没有将g ++调用别名为始终使用-isysroot
,而是将/Applications/.../MacOSX10.14.sdk/usr/include
添加到了
I had the headers installed in /Applications/.../MacOSX10.14.sdk/usr/include
. Instead of aliasing my g++ calls to always use -isysroot
, I added /Applications/.../MacOSX10.14.sdk/usr/include
to my CPLUS_INCLUDE_PATH
.
我使用并添加到.bash_profile
中的确切代码行是
The exact line of code I used and added to my .bash_profile
was
export CPLUS_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
我觉得这是一个更优雅的解决方案,因为据我了解,使用 isysroot
或sysroot
会告诉g ++不要在默认位置搜索,这时您可能需要同时包含Mac SDK目录和通常的/usr/include
,/usr/local/include
等.
I feel that this is a more elegant solution, since from what I understand using isysroot
or sysroot
will tell g++ to not search in the default places, when you may need includes from both the mac SDK directory and the usual /usr/include
, /usr/local/include
, and so on.