gpt4 book ai didi

c++ - 我第一次接触Boost...包含错误

转载 作者:行者123 更新时间:2023-11-28 03:55:20 24 4
gpt4 key购买 nike

我正在尝试运行 boost 示例,但出现以下错误:

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

我应该在编译时提供任何额外的选项吗?

最佳答案

您必须提供将文件 boost 到 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

关于c++ - 我第一次接触Boost...包含错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3848545/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com