2

If for example I have compiled a simple C program that uses GTK 3 on a machine running Ubuntu, will I be able to run it on other Linux flavours?

Note: My actual questions is "Should I label my compiled program for Linux or just Ubuntu?"

eg. Should I label my downloads page as

Windows
    program.exe

Linux
    program

Macintosh
    program.app

or

Windows
    program.exe

Ubuntu < Version 17.04
    program

Macintosh
    program.app
  • Ideally you would produce a deb file, perhaps even submit the source to debian so it would eventually end up in production versions of ubuntu, mint, etc. In the mean time, it would be good to have your own debs, rpms (for redhat, etc) plus source available. – ivanivan Apr 24 '17 at 0:27
3

Linux executables are not specific to a Linux distribution. But they are specific to a processor architecture and to a set of library versions.

An executable for any operating system is specific to a processor architecture. Windows and Mac users don't care as much because these operating systems more or less only run on a single architecture. (OSX used to run on multiple processor architectures, and OSX applications were typically distributed as a bundle that contained code for all supported processor architectures, but modern OSX only runs on amd64 processors. Windows runs on both 32-bit and 64-bit Intel processors, so you might find “32-bit” and “64-bit” Windows executables.)

Windows resolves the library dependency problem by forcing programmers to bundle all the libraries they use with their program. On Linux, it's uncommon to do this, with the benefit that programmers don't need to bundle libraries and that users get timely security updates and bug fixes for libraries, but with the cost that programs need to be compiled differently for different releases of distributions.

So you should label your binary as “Linux, 64-bit PC (amd64), compiled for Ubuntu 17.04” (or “32-bit PC (i386)” if this is a 32-bit executable), and give the detail of the required libraries. You can see the libraries used by an executable with the ldd command: run ldd program. The part before the => is what matters, e.g. libgtk-3.so.0 is the main GTK3 library, with version 0 (if there ever was a version 1, it would be incompatible with version 0, that's the reason to change the version number). Some of these libraries are things that everyone would have anyway because they haven't changed in many years; only experience or a comparison by looking at multiple distributions and multiple releases can tell you this. Users of other distributions can run the same binary if they have compatible versions of the libraries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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