加载 boost 共享库时出错

发布于 2024-10-10 00:08:09 字数 186 浏览 0 评论 0原文

我正在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一袭白衣梦中忆 2024-10-17 00:08:09

除了其他答案之外,您还可以在链接可执行文件时设置 DT_RPATH elf 标记。

-Wl,-rpath,/path/to/boost/libraries -L /path/to/boost/libraries -lboost_whatever

这样,如果库是,则不必记住设置 LD_LIBRARY_PATH安装在非标准位置。

In addition to the other answers, you can also set the DT_RPATH elf tag when linking your executable

-Wl,-rpath,/path/to/boost/libraries -L /path/to/boost/libraries -lboost_whatever

This way you don't have to remember to set your LD_LIBRARY_PATH if the libraries are installed in a non-standard location.

梦忆晨望 2024-10-17 00:08:09

你是如何安装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

剩余の解释 2024-10-17 00:08:09

您需要设置 LD_LIBRARY_PATH 环境变量以包含 Boost 库的路径(它们可能位于 /usr/local/lib 等)。

在 bash 中,这只是

export LD_LIBRARY_PATH=/path/to/boost:$LD_LIBRARY_PATH

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

export LD_LIBRARY_PATH=/path/to/boost:$LD_LIBRARY_PATH
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文