【发布时间】:2012-06-23 15:25:38
【问题描述】:
我已经安装了libboost-dev到apt-get,它放在/usr/lib中。
/usr/lib$ ls | grep boost
libboost_filesystem.so.1.46.1
libboost_iostreams.so.1.46.1
libboost_serialization.so.1.46.1
libboost_system.so.1.46.1
libboost_thread.so.1.46.1
libboost_wserialization.so.1.46.1
但是当我尝试编译使用boost_thread 的源代码时,我仍然遇到错误。
$ g++ tcp_echo.cpp -o tcp_echo -L/usr/lib -llibboost_thread
/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status
$ g++ tcp_echo.cpp -o tcp_echo -L/usr/lib -lboost_thread
/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status
安装和链接到libboost 的正确方法是什么?
【问题讨论】:
-
您不需要
-L/usr/lib,它会自动添加到库搜索路径中。 -
您是否尝试在安装后运行
ldconfig(以root 身份)? -
@JoachimPileborg ldconfig 应该由 apt 运行,所以他应该很好。尤其是如果
-L仍然被使用。 -
你试过重新安装吗?
-
我注意到的一件事是你没有 libboost_thread.so。您有版本化的 1.46.1 文件,但通常库会创建一个符号链接到带有未修饰名称的版本化副本。可能不是这样,但这是我注意到的一件事。 (这通常由安装程序完成。)