英文:
Can C/C++ build all dynamic libraries into one bin file?
问题
当我在不同的操作系统上开发时,我发现在一个Linux系统上构建的程序无法在另一个系统上运行,这是因为不同的libc版本。
我该如何像Go语言在C/C++中那样构建包含所有共享库的程序?
包括libc和libcxx。
英文:
When I develop across different OS's I find that a program built on one Linux system can not be run on another system, due to the different libc version.
How can I build in all the shared libraries just like golang did in c/c++?
Including libc and libcxx
答案1
得分: 2
如果你想在多个Linux系统上运行,你只需要使用其中任何一个系统中最旧的glibc进行构建即可。最简单的方法是从像CentOS 5这样的旧系统中下载一个虚拟机镜像,然后在那里进行构建。你不需要担心静态链接,只需针对旧版本进行构建,就能与较新版本基本兼容。
英文:
If you want to run on multiple Linux systems, all you really need is to build using the oldest glibc from any of them. The easiest way is to simply download a virtual machine image from an old system like CentOS 5 and build there. You don't need to worry about static linking, just building against an old version will mean you are mostly compatible with newer versions.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论