Issues of running C++11 executable compiled with gcc 4.7 on a computer with an older gcc / glibc / libstdc++

旧城冷巷雨未停 提交于 2019-12-23 03:22:33

问题


I am a newbie to C++ compilation in production environment I wonder if there are any issues in running a C++11 executable compiled with gcc4.7 ( on debian 6 ) on a computer with an older gcc version, an older glibc / libstdc++.

Thanks

EDIT :

I want to add more details to my question ( maybe it's better to open a new question ? )

I need to compile a legacy C++ code with new libs in C++11

  • on debian 7 ( for gcc 4.7 ) and run the exe on debian 6
  • on fedora 18 ( for gcc 4.7 ) and run the exe on centos 6

How to achieve this ?


回答1:


It really depends on the system, but in general, for libc, there shouldn't be any real problem, unless you're using some special functions that were only added very recently. One of the design goals of libc is that it remain compatible for all time.

libstdc++ is a different matter, and I would strongly recomment statically linking it (-static-libstdc++).



来源:https://stackoverflow.com/questions/17151227/issues-of-running-c11-executable-compiled-with-gcc-4-7-on-a-computer-with-an-o

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