Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The title says it all, actually. But allow me to specify the question:

Assuming I were to compile an application that uses libffi, libGL, dlfcn, and SDL, would said binary run on other Linux distributions with same architecture, etc?

The reason I ask is because of the directory /usr/lib/i386-linux-gnu - I might be wrong, but I assume this directory is something rather Ubuntu-specific, no?

So, how portable are binaries compiled on Ubuntu really?

share|improve this question
That directory's not especially Ubuntu-specific. It's the location of the 32 bit binaries on a 64 bit system. (Run dpkg -S /usr/lib/i386-linux-gnu). Most distros have something like this though there are a few variations, and in particular it's different on RedHat-derived distros. –  poolie Mar 29 '12 at 6:21
Are you asking about this from the user perspective of "can I just copy random programs around?" (answer: no), or the developer perspective of "can I make one binary that will run on different systems?" (answer: yes, with some work.) –  poolie Mar 31 '12 at 22:58
add comment

2 Answers

When you compile a binary, say, nginx from source code, it's built with information regarding what versions of the libraries are on the system that is compiling the binaries. The libraries to reference of course are determined by the arguments (for nginx, that's the definition of which modules you want activated or not). But that binary which you built will (unlikely) run on a separate system, unless its an identically-configured system.

You will want to compile the application on each individual system, its (relatively) unlikely you will be able to port the compiled version to another system that might not have a compatible version of each library.

Note: While you can get a binary to port to another Linux system, its ill-advised and usually is time consuming. This is because:
(1) You need to make sure the system you're going to move your binary to is using the same version of libc that was used to compile the binaries
(2) You need to make sure that the libraries used within the program are able to be detected easily on your system, and that they are the same (or compatible) versions as were used to create the program.

...and of course other variables to consider. It's just easier in the long run to compile the program on each system to use it rather than try to strive for portability.

share|improve this answer
This also applies to other linux development environments, as well, such as Arch, Gentoo, etc. –  Thomas W. Mar 29 '12 at 4:18
Well, moving a binary that's dynamically linked against lots of distro libraries will be hard. But see question about building portable binaries in other ways, by either static linking or using the LSB. –  poolie Mar 29 '12 at 6:18
@poolie not every program is portable. More often than not, programs aren't written in a manner that is portable. –  Thomas W. Mar 29 '12 at 14:32
Libraries are referenced by simple name, not full path, so the same binary can run on another machine that has the library in another location, or you can have multiple versions of the library in different locations, and change the library search path when you run the program to direct it to one or the other. You should only run into issues with library versions if the program uses functions from the library that were added in a newer version than what the system has installed. –  psusi Mar 29 '12 at 14:42
@psusi having said this, do you believe that its more feasible (and easier) to compile a program on each system that will use it, or to distribute Linux binaries that may use newer features than the libraries available on each system using the program? –  Thomas W. Mar 29 '12 at 14:43
show 2 more comments

Generally, yes, but it depends. Libraries sometimes add new functions. If you start using those new functions, then you now depend on that version of the library ( since older versions didn't have it ). As long as the system has the libraries you need, with at least the minimum versions you require ( and is the same architecture ), the program will run just fine.

If you are packaging the program, the debian package system has facilities to detect what functions you call in the libs and figure out the minimum version you require, so that the package can specify that information so when people install it on a debian based system, it can make sure they have the required libs. When following this proceedure, it is generally possible to build a .deb on Ubuntu that will install and run on say, debian and mint, and any realease that meets your minimum library requirements.

See http://www.debian.org/doc/debian-policy/ch-sharedlibs.html

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.