GCC 不使用 Boost 文件夹包含标志

GCC not using Boost folder include flag

我有一个项目,其中包含一个使用 boost 1.57 的库,该库也包含在内。但是,GCC 编译器(默认 Xcode CLI 工具 v6.0 GCC 版本 4.2.1)不会选取提升包含目录,而会选取其他目录。这是怎么回事?

这是发出的最后一个 GCC 命令:

gcc -g -stdlib=libstdc++ -Wall -Wno-error -ferror-limit=1000 -fmessage-length=0 
-DHCUBE_NOGUI -DTIXML_USE_STL -DMACOS -mmacosx-version-min=10.5 -arch i386 -arch x86_64 
-I/Applications/Webots6.3.0/include/controller/c 
-I/Users/mtw800/experimentSuite/experiment/../HyperNEAT/tinyxmldll/include 
-I/Users/mtw800/experimentSuite/experiment/../HyperNEAT/NE/HyperNEAT/NEAT/include 
-I/Users/mtw800/experimentSuite/experiment/../HyperNEAT/JGTL/include 
-I/Users/mtw800/experimentSuite/experiment/../HyperNEAT/boost_1_57_0/boost/ -DXML1 
-c ModHyperNEAT/mod_ctrler7.cpp  -o controllers/mod_ctrler7_1.o

GCC 给我的错误:

In file included from ModHyperNEAT/mod_ctrler7.cpp:30:
In file included from /Users/mtw800/experimentSuite/experiment/../HyperNEAT/NE/HyperNEAT/NEAT/include/NEAT.h:4:
In file included from /Users/mtw800/experimentSuite/experiment/../HyperNEAT/NE/HyperNEAT/NEAT/include/NEAT_Globals.h:4:
/Users/mtw800/experimentSuite/experiment/../HyperNEAT/NE/HyperNEAT/NEAT/include/NEAT_Defines.h:23:10: 
fatal error: 'boost/shared_ptr.hpp' file not found
#include <boost/shared_ptr.hpp>
     ^
1 error generated.
make: *** [experiment-modular] Error 1

提升包含路径:

-I/Users/mtw800/experimentSuite/experiment/../HyperNEAT/boost_1_57_0/boost/

存在并调用 find `pwd` -name shared_ptr.hpp 给出以下结果:

MW-020708:boost_1_57_0 mtw800$ pwd
/Users/mtw800/experimentSuite/HyperNEAT/boost_1_57_0
MW-020708:boost_1_57_0 mtw800$ find `pwd` -name shared_ptr.hpp
/Users/mtw800/experimentSuite/HyperNEAT/boost_1_57_0/boost/asio/detail/shared_ptr.hpp
/Users/mtw800/experimentSuite/HyperNEAT/boost_1_57_0/boost/interprocess/smart_ptr/shared_ptr.hpp
/Users/mtw800/experimentSuite/HyperNEAT/boost_1_57_0/boost/serialization/shared_ptr.hpp
/Users/mtw800/experimentSuite/HyperNEAT/boost_1_57_0/boost/shared_ptr.hpp
/Users/mtw800/experimentSuite/HyperNEAT/boost_1_57_0/boost/smart_ptr/shared_ptr.hpp
/Users/mtw800/experimentSuite/HyperNEAT/boost_1_57_0/boost/thread/csbl/memory/shared_ptr.hpp

所以我知道 boost 包含库在那里,路径是正确的,甚至 shared_ptr 的头文件也在那里。为什么 GCC 不获取我的包含文件夹路径?

我已经通过删除所有 -I 标志并在 GCC 给出无法找到它们的错误时重新添加它们来测试其他包含路径正在被拾取(因为它们应该)。

奇怪的是,如果我用 home-brew 安装 boost,并且不做任何更改,我的编译脚本只是 'works',因为 homebrew 可能将 boost 链接到默认情况下由 GCC 搜索的目录.这很好,但是,我不希望 GCC 使用自制软件提升,因为它必须在不使用自制软件的系统上编译。我该怎么办?为什么 GCC 只排除一个包含文件夹而不排除所有其他文件夹来困扰我?这里发生了什么样的非确定性编译器 automagick?

我正在使用 OSX Yosemite 10.10,上面提到了 Xcode 开发人员工具。另一台计算机使用相同的 OSX 和相同的 GCC(相同的 Xcode 开发工具)。

您需要从以下位置删除最后一个元素 (boost):

-I/Users/mtw800/experimentSuite/experiment/../HyperNEAT/boost_1_57_0/boost/

给定源文件使用 #include <boost/whatever.h>,预处理器希望在搜索包含目录时找到 boost 子目录。