Will a C++ Linux app built on version X.XX of the kernel run on an earlier version?

This question may seem blindingly obvious and I realise I am putting myself up for a large number of downvotes but I am very new to Linux dev and have only been working on it for a while.

I have been writing an application on ubuntu 12.04 (kernel 3.2.0) in C++ then copying this via scp to an ubuntu 8.04 (kernel 2.6.30) installation on another device. I have been noticing some very strange behaviour that I simply cannot explain. I have naively assumed that I can run this executable on a previous version, but it is beginning to dawn on me that this in fact may not be the case. In future must I ensure that the Linux version I build my application on is identical to that which it will be running on in the field?? Or must I actually build the application from source code directly on the device it will be running on??? I am very new to Linux dev but not new to C++ so I realise that this question may seem facile, but this is the kind of issue that I have simply not seen in books/tutorials etc.

Answers


Most of the time, it's not the kernel that stops you, it's glibc.

glibc is backwards compatible, meaning programs compiled and linked to an older version will work exactly the same with a newer version at runtime. The other way around is not that compatible.

Best is of course to build on the distro you want to run it. If you can't do that, build on the one with the oldest glibc install.

It's also very hard to build and link to an older glibc than the system glibc, installing/building glibc tends to mess up your system more than it's worth. Set up a VM with an old Linux, and use that instead.


Need Your Help

Android volley How to send request with both authentification headers and Json object in body

android json android-volley

I need to send via volley a http request with both authentification header and Json object in body. Bu I did not found a request for this in volley.

How fast (slow) is Quercus PHP on Resin Open Source as opposed to Resin Professional?

java php resin quercus

The clever folks at Caucho are quick to point out that Quercus is 3x-5x faster than straight mod_php (without APC). But digging deeper in the documentation, you'll see that the PHP-to-bytecode