加载 boost 共享库时出错
我正在centos上工作。我在我的系统上安装了 boost 版本 1.45.0。程序已正确编译,但每当我键入命令查看输出时,都会出现以下错误:
./a.out:加载共享库时出错: libboost_thread.so.1.45.0:无法打开共享对象文件:没有这样的 文件或目录
I am working on centos. I installed boost version 1.45.0 on my system. The programs are compiled correctly but whenever I type command to see output it gives following error:
./a.out: error while loading shared libraries:
libboost_thread.so.1.45.0: cannot open shared object file: No such
file or directory
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了其他答案之外,您还可以在链接可执行文件时设置
DT_RPATH
elf 标记。这样,如果库是,则不必记住设置
LD_LIBRARY_PATH
安装在非标准位置。In addition to the other answers, you can also set the
DT_RPATH
elf tag when linking your executableThis way you don't have to remember to set your
LD_LIBRARY_PATH
if the libraries are installed in a non-standard location.你是如何安装boost库的?
您可能遇到的问题是链接器找不到库,并且当您构建程序时,您必须手动指定其他库路径来搜索库。
您可以做的快速修复是设置
LD_LIBRARY_PATH
以包含boost线程库所在的目录:export LD_LIBRARY_PATH=/path/to/boost/libs:$LD_LIBRARY_PATH
<代码>./runExecutable
How did you install the boost libraries?
The problem you're likely having is that the linker can not find the libraries, and when you built your program, you had to manually specify additional library paths to search for libraries.
A quick fix you can do is to set
LD_LIBRARY_PATH
to include the directory where the boost thread library is:export LD_LIBRARY_PATH=/path/to/boost/libs:$LD_LIBRARY_PATH
./runExecutable
您需要设置 LD_LIBRARY_PATH 环境变量以包含 Boost 库的路径(它们可能位于 /usr/local/lib 等)。
在 bash 中,这只是
You need to set the
LD_LIBRARY_PATH
environment variable to include the path to the Boost libraries (they're possibly in/usr/local/lib
, etc).In bash, this is simply