How do I compile binaries that work on older Linux distributions?

I have Ubuntu 16.10. How can I compile a C ++ program to make the binary work correctly on Ubuntu 14.04 or any other Linux distribution of a similar age? (I'm only interested in x86-64.)

Is this achievable with the default compiler on 16.10 (gcc 6.2) or do I need to install and use the same compiler on 14.04 (gcc 4.8)? If I need an old compiler, do I need packages -multilib

?

I am interested in both a general (distribution) explanation of what is needed for compatibility, as well as more specific hints on how to do this in my version of Ubuntu.

+3


source to share


1 answer


An ugly solution would be to link everything (including the C ++ runtime) statically to create a huge monolithic executable that doesn't depend on system libraries in the same way (like it does in go language). Another ugly solution would be to install some CI and build everything on all supported systems. However, this would most likely mean writing everything with the oldest supported system in mind and struggling with compatibility issues.



0


source







All Articles