PDA

View Full Version : Which Linux distribution is best for building compatible apps?



Oxidative
27th April 2009, 23:04
I'm trying to build my application so that it can be run on as many linux distributions as possible without any additional dependencies. For that, I build Qt statically and link my app against it. Now I can run the app on any linux that uses the same gcc and glibc ABIs.

Since I'm using Gentoo on my box, I always have the latest versions on my system. As a result, the apps I build are also dependent on the latest gcc/glibc. That's definitely not what I want. I can for example not run my app on a distribution which is two years old.

I did some research on my options:
Linking gcc and glibc statically: this doesn't seem to be an option according to http://www.trilithium.com/johan/2005/06/static-libstdc/
statifier (http://statifier.sourceforge.net/): doesn't work reliable. On some distributions, this will silently crash the app.
LSB: basically a great idea, especially the possibility to run a test to see on which distributions the app will run/not run. However, this only covers very popular or enterprise distributions. A good example that this doesn't suit me: Gentoo has no LSB support at all! No way to run such an app on my system. So that's not an option for me either.
Building with a very old version of gcc/glibc: the ABIs should be backward compatible. So if I build with gcc 3.4.6 and glibc 2.3.2, the app should run on any sytem that uses the same version or above. I've looked into creating a cross-compiling environment for those old libs, but that's acutally pretty nasty thing todo. It appears to be easier to simply build my app on an old linux distribution that has the suitable versions.

So here is my question: what's the best linux distribution regarding gcc/glibc compatibility? My guess is it should an old distribution, maybe something from 2005 or before. I've tried building on CentOS 4.7 (RHEL4-based, gcc 3.4.6, glibc 2.3.4 and an quite pleased by the result: the resulting executable runs fine on my gentoo, on Knoppix 5.2 and Debian Sarge 3.1. Does anyone around here have any experience on the subject or can recommend a better option/distribution?

ComaWhite
27th April 2009, 23:15
Well what you can do is get a list of all the popular distros, write deb files for ubuntu, debian, write an ebuild for Gentoo, write an rpm for Suse. But first check and see what comes out of the box for those distros and compile against those.

Oxidative
27th April 2009, 23:19
That would require to build the app on all those distributions seperatly, no?

ComaWhite
27th April 2009, 23:24
Well since me and you use Gentoo (we have to compile ourself using ebuilds). I don't know much about Debian. But usually when creating a deb file, you compile yourself and what not, same with rpm. But that's what i'd do. Create package manager's package. And for the ones you have to compile yourself. Go with what they ship with their distro out of the box. But more usually it's GCC-4.2.x to GCC-4.3.x.

Lykurg
28th April 2009, 11:28
That would require to build the app on all those distributions seperatly, no?
No, you can create the packages for all distros on your own machine. And only once. The executable is only packed in a different way in deb or rpm, but the executable is the same using gcc***. The distros find the needed libraries themselves.

wysota
28th April 2009, 21:00
The best way is to provide source code of your application. This is compatible with every linux distro. You can even provide a .spec file for your package that will build the package by calling qmake, make and make install on every possible rpm-based distro.

Oxidative
29th April 2009, 00:56
No, you can create the packages for all distros on your own machine. And only once. The executable is only packed in a different way in deb or rpm, but the executable is the same using gcc***. The distros find the needed libraries themselves.

I'd have to figure out the required dependencies for every distribution. I don't want to write a specific package for every possible distribution out there. Providing distribution specific packages is a job for the packaging community, not for me as a developer.


The best way is to provide source code of your application. This is compatible with every linux distro. You can even provide a .spec file for your package that will build the package by calling qmake, make and make install on every possible rpm-based distro.
I totally agree with you, offering the source package is a must. But those packages are for more advanced users or package builders. I want to offer a package for the convenient users, who don't care about installing the software a "proper way", who just wants to be able to run the software somehow. As far as I can see, a .spec file will always be for a specific distribution because of the dependencies. And then again, not every distribution is using rpm or deb...

wysota
29th April 2009, 01:30
I'd have to figure out the required dependencies for every distribution. I don't want to write a specific package for every possible distribution out there. Providing distribution specific packages is a job for the packaging community, not for me as a developer.
That's why sticking to LSB is the best choice if you want to distribute your application in a binary form.



I totally agree with you, offering the source package is a must. But those packages are for more advanced users or package builders. I want to offer a package for the convenient users, who don't care about installing the software a "proper way", who just wants to be able to run the software somehow. As far as I can see, a .spec file will always be for a specific distribution because of the dependencies. And then again, not every distribution is using rpm or deb...

You can't satisfy them all. You can provide an installer script that will call qmake (or cmake), make and optionally make install and will build the application in the background. If your application only depends on Qt, this shouldn't be a problem (even if you want to distribute a .spec file). But in general unless you build your application statically, there is a chance your application won't work on some of the distros. And even that won't make your application run on different architectures. Sometimes people tend to forget the world is something more than just x86.

nooky59
9th July 2009, 17:13
Hello,

I asked (and still think about it) myself the same questions.

You are right and I already posted about it on this forum, the best Linux distro to build an app is CentOS / RHEL because this is the only one that is maintained for 7 years so you can run a security updated OS with old libs.

So, you can be sure that all the other Linux distros maintained will use fresher libs.

I used until recently CentOS 3 but with Qt 4.5, it began to be a pain to compile Qt so I switched to CentOS 4. CentOS 3 will expire next year so it was not so important to stick with it.

Next, how to distribute your app. If you don't use exotic libs, I think all dependencies will be met if someone install a popular Linux distro in a standard way (without stream-lined it too much).

So the bash wrapper script with LD_LIBRARY_PATH could be the best (if you need to link dynamically, it's required if you want to use the LGPL release of Qt) and it will be simple for users to untar and unzip it and use it without the need to be root to install the software.

But in case of explicit needs when you really need dependencies or doing some stuffs on the system when installing, I have wrapped binary and Qt libs (all build on the CentOS 4) in a deb file on the latest Debian (it run fine both on Debian & Ubuntu) and on a RPM that seems to be generic enough to run both on Red Hat / Mandriva & SuSE systems