在ubuntu上设置boost库的问题

时间:2009-12-30 23:46:42

标签: c++ boost

我已经在ubuntu 9.10中的'/ media / data / bin'中编译并安装了我的boost库。 我已经设置了INCLUDE_PATH,LIBRARY_PATH env:

$ echo $INCLUDE_PATH
/media/data/bin/boost/include:
$ echo $LIBRARY_PATH
/media/data/bin/boost/lib:

但是当我编译asio示例时,我收到以下错误: $ g ++ blocking_tcp_echo_server.cpp

blocking_tcp_echo_server.cpp:13:26: error: boost/bind.hpp: No such file or directory
blocking_tcp_echo_server.cpp:14:31: error: boost/smart_ptr.hpp: No such file or directory
blocking_tcp_echo_server.cpp:15:26: error: boost/asio.hpp: No such file or directory
blocking_tcp_echo_server.cpp:16:28: error: boost/thread.hpp: No such file or directory
blocking_tcp_echo_server.cpp:18: error: ‘boost’ has not been declared
blocking_tcp_echo_server.cpp:22: error: ‘boost’ has not been declared
blocking_tcp_echo_server.cpp:22: error: expected initializer before ‘<’ token
blocking_tcp_echo_server.cpp:24: error: variable or field ‘session’ declared void
blocking_tcp_echo_server.cpp:24: error: ‘socket_ptr’ was not declared in this scope

4 个答案:

答案 0 :(得分:10)

有什么问题
sudo apt-get install libboost-dev

之后您无需设置任何-I-L标志。如果你需要Boost 1.40,你仍然可以重建当前的Debian unstable包。

答案 1 :(得分:3)

为了节省每个人的时间,这是我在其他地方给出的这个问题的答案: http://permalink.gmane.org/gmane.comp.lib.boost.user/54626

更新2016-02-11:有必要直接指定选项:

g++ -I<prefix>/include -L <prefix>/lib

或使用正确的变量:

export CPLUS_INCLUDE_PATH=<prefix>/include
export LIBRARY_PATH=<prefix>/lib

答案 2 :(得分:0)

尝试C_INCLUDE_PATH或使用-I编译器选项

BTW,使用LD_LIBRARY_PATH来帮助查找库

答案 3 :(得分:0)

检查标题是否确实存在:

/media/data/bin/boost/include/boost/bind.hpp

还尝试使用-I / media / data / bin / boost / include而不是env变量(在-I之后注意没有空格)。