我正在尝试运行一个提升示例,但我收到以下错误:
g++ bimap.cpp -o bimap
bimap.cpp:1:28: error: boost/config.hpp: No such file or directory
bimap.cpp:8:27: error: boost/bimap.hpp: No such file or directory
bimap.cpp: In function 'int main()':
bimap.cpp:27: error: 'boost' has not been declared
bimap.cpp:27: error: expected initializer before '<' token
bimap.cpp:28: error: 'results_bimap' has not been declared
bimap.cpp:28: error: expected initializer before 'position'
bimap.cpp:30: error: 'results_bimap' was not declared in this scope
bimap.cpp:30: error: expected `;' before 'results'
bimap.cpp:31: error: 'results' was not declared in this scope
bimap.cpp:31: error: 'position' was not declared in this scope
但我的环境变量设置如下:
BOOST_HOME /apps/rhel5/boost_1_39_0
BOOST_INCLUDE -I/apps/rhel5/boost_1_39_0/include/boost-1_39/
LINK_BOOST -L/apps/rhel5/boost_1_39_0/lib -Xlinker -rpath -Xlinker /apps/rhel5/boost_1_39_0/lib
我应该在编译时提供任何额外选项吗?
答案 0 :(得分:2)
您必须提供将文件提升为g ++本身的路径。
试试这个:
g++ bimap.cpp -I/apps/rhel5/boost_1_39_0/include/boost-1_39/ -L/apps/rhel5/boost_1_39_0/lib -Xlinker -rpath -Xlinker /apps/rhel5/boost_1_39_0/lib -o bimap
或(TokenMacGuy解决方案):
g++ bimap.cc $BOOST_INCLUDE $LINK_BOOST