GCC Compiler, compile app for lower version of GCC

Viewed 469

I'm developing C++ application on Debian machine with installed GCC 6.3.0 x64 architecture, but the application would run on Centos with GCC 4.4.7 x86.

How do I compile my app for the target environment? Is the only way to do that is to install GCC 4.4.7 on my host machine?

1 Answers

You can build with your GCC 6.3, but you should use the -D_GLIBCXX_USE_CXX11_ABI=0 option to use the older ABI to be compatible with GCC older than 4.9. Otherwise it will not run properly on the target system.

To be absolutely sure of compatibility, you can indeed use the toolchain of the target system. You don't need to install it on your machine directly though. You can compile in a virtual machine running the older distro, or use docker (or some other container system).

Related