libstdc++ 的库搜索路径

发布于 2024-10-29 20:06:08 字数 432 浏览 7 评论 0原文

我已经使用 GLIBCXX_3.4.11 编译了动态链接到 libstdc++.so 的共享库。我想将我的代码发送给 stdc++ 库仅为 3.4.10 版本的人。我不想要求他更新他的库版本(这是软件客户,所以我不能假设他们愿意或能够更改系统文件),我想提供适当版本的 libstdc++.so,放置在lib 文件夹,其中包含我的代码的目录位置。如何让我自己的代码使用适当的(更高版本)版本?我发现 /etc/ld.so.conf 包含目录 /lib64,其中存在有问题的旧版本 libstdc++.so。设置 LD_LIBRARY_PATH 不会覆盖此设置。这似乎偏离了广告行为。知道为什么会发生这种情况吗?我如何完成相当简单的任务?

谢谢。

I have compiled shared libraries dynamically linked against libstdc++.so using GLIBCXX_3.4.11. I want to send my code to someone whose stdc++ library is only of version 3.4.10. Rather than ask him to update his library version (this is a software customer, so I can't assume they'll be willing or able to change system files) I would like to ship the appropriate version of libstdc++.so, placed in a lib folder with the directory location of my code. How do I get my own code to use the appropriate (later) version? I find that /etc/ld.so.conf includes the directory /lib64, where an offending older version of libstdc++.so resides. Setting LD_LIBRARY_PATH does not override this. This seems to deviate from the advertised behavior. Any idea why this is happening? How do I complete my rather simple task?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

情仇皆在手 2024-11-05 20:06:08

我知道这个问题很旧,但我在尝试解决我自己的类似链接问题时发现了它。您必须根据与您同事的库版本兼容的 libstdc++ 版本来构建您的程序。当然,最简单的解决方案是链接到他的库版本,这样他就不需要在他这边进行特殊的调整来链接您的库。

为此,您需要安装一个可以构建二进制兼容库的 GCC 版本,以便您可以实际链接到他的 libstdc++ 版本。 GLIBCXX_3.4.11 来自 gcc-4.4 及更高版本,因此您需要 gcc-4.3。使用它构建您的程序,您应该处于良好状态。

您可以查阅以下页面以获取库 ABI 兼容性列表:
http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html

您还可以构建一个 rpm/deb,它需要您已有的 libstdc++ 版本,如果不可用,请拒绝安装。这为您提供了一个界面,向他保证,如果他的系统设置了正确的依赖项,他就可以使用您的库。从这个意义上说,它就像是针对您支持和不支持的内容的库的松散 SLA。

希望有帮助!

I understand that this question is old, but I found it while trying to sort out my own linking trouble which was similar. You will have to build your program against a version of libstdc++ which is compatible with your colleague's version of the library. The easiest solution, of course, is to link against his version of the library so he doesn't need to make special tweaks on his side to link your library.

To do this, you will want to install a version of GCC which can build binary compatible libraries so you can actually link against his version of libstdc++. GLIBCXX_3.4.11 is from gcc-4.4 and later, so you will need gcc-4.3. Build your program using this and you should be in good shape.

You can consult the following page for a list of library ABI compatabilities:
http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html

You could also build an rpm/deb which requires the version of libstdc++ you already have and if it's not available, refuse to install. This gives you a bit of an interface which gives him a promise that if his system is setup with the correct dependencies, he can use your library. In that sense, it's like a loose SLA for your library in what you do and don't support.

Hope that helps!

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