About the binary compatibility of Linux

徘徊边缘 提交于 2019-12-30 10:27:18

问题


If I get some C++ code built by, lets say, GCC 4.8 on Ubuntu, the code has no GUI/interface, only call standard Linux libraries, then can the binary run on RHEL 5/6, with much older GCC flawlessly?


回答1:


Normally it can't. It will complain about libc being too old, for one.

If you statically link with libstdc++ and carefully avoid newer glibc features, you may be able to get away with it. The latter is not always possible though. Static linking with libc is not officially supported and may work or not work for you.




回答2:


The issue is probably more Glibc than libstdc++ (which you can indeed link statically) or GCC itself.

You could use an alternative Libc, such as MUSL libc (which is supposed to be more friendly with static linking)

Also, there might be some kernel dependencies.



来源:https://stackoverflow.com/questions/20800093/about-the-binary-compatibility-of-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!