独立于共享库的linux二进制文件
我有一个 C++ 程序,它依赖于相当多的库(一些常见的系统库,如 libjpeg 和一些未在系统范围内安装的个人库)。该程序在机器 A (Debian Squeeze) 上编译良好。我想在机器 B (Ubuntu maveric) 和机器 C (Arch) 上运行该程序。假设两台机器 B+C 都是极简安装。不要指望在那里找到我的程序使用的任何库,即使有,它们也不是同一版本。
是否有任何程序可以扫描我的程序的所有依赖项(使用 ldd 或其他东西)收集所有这些依赖项,并生成一个脚本来告诉二进制文件使用这些依赖项,并且仅使用它在任何其他系统上附带的这些库?
谢谢 !
I have a C++ program that depends on quite a few libraries (some common system libraries like libjpeg some personal libraries that are not installed system wide). The Program compiles well on machine A (Debian Squeeze). I would like to run the program on machine B (Ubuntu maveric) and machine C (Arch). Assume that both machines B+C are extremly mininmal installations. Don't expect to find ANY libraries that my program uses on there and if there are any they are not the same version.
Is there any program that can scan my program for ALL dependencies (using ldd or something) gather all those dependencies, and generate a script that will tell the binary to use these and only these libs it comes with on any other system ?
Thank you !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不是 100% 确定我理解你的问题,但似乎你想将库与你的包一起发布,并使用 LD_LIBRARY_PATH 强制链接器在执行其他操作之前先查看你发布的库目录。
如果还有更多内容,我可以修改我的答案,因为我对此有一些经验。只是想确保我知道你在要求什么。
I'm not 100% sure I understand your question, but it seems like you want to ship the libraries with your package, and use LD_LIBRARY_PATH to force the linker to look in your shipped library directory before anything else.
If there's more to it, I can revise my answer as I have some experience with this. Just want to make sure I know what you're asking for.
事实证明,您问题的答案是静态链接,例如使用 g++ -static。
It turns out the answer to your question is to link statically, say with g++ -static.