views:

67

answers:

4

I'm wondering which Linux distribution would be best (i.e. introduces the least dependencies) when linking a binary that should work on as many distributions as possible against shared libraries.

I've done it on Ubuntu, but the list of dependencies is horrible. SDL introduces PulseAudio and whatnot. My next guess would be to use Debian lenny - what's the best distribution for that in your opinion?

+2  A: 

If you do not want to release your source and compile it on the target systems using an installation script, then provide everything statically linked or ship your own so files and use LD_LIBRARY_PATH and LD_PRELOAD environment variables in the script used to start your executable. (An example on how it is done can be seen in the mozilla firefox packaging)

Also legal issues apply: NEVER use GPL code. And do never link statically against LGPL code (among other issues).

Any other solution leaves too much room for good or bad luck and will generate nothing but frustration.

jdehaan
Oh, very good hint with static linking and LGPL code, I would have missed that...
Noarth
+1  A: 

If I recall correctly, linking against SDL on one distro that has pulseaudio as an SDL dependency does not mean your program must always be linked against pulseaudio on every distro. You don't actually have to put an -lpulseaudio on your compile line, do you? sdl-config --libs on my Ubuntu box doesn't list it.

Karl Bielefeldt
It doesn't list pulseaudio, but if you check libSDL.so with ldd, it will list pulseaudio among other stuff.
Noarth
The thing is that your compiled binary only includes libSDL.so references, not the references to pulseaudio. On the target machine, the dynamic linker will only try to resolve your references to libSDL.so first. Then, if libSDL.so there references other libs, it will go search for them. They may include pulseaudio, may not. Your binary will be linkable without pulseaudio.
ypnos
A: 

If you look at QT documentation, http://doc.trolltech.com/4.6/deployment-x11.html section "Creating the Application Package" they suggest to create a package like a Mac bundle, with a shell script to start it.

You can do the same thing; you will have to create the libraries you need and include them in your package which will make it bigger unfortunately. At least this should encourage you to only link to the libs you need :)

koan
Good link, thank you. I'm planning to include all required shared objects - except LSB libraries. Do you recommend that I build my required libraries myself? I could probably build e.g. SDL with few dependencies if I do, but I'm not sure how I can teach CMake to link against that.
Noarth
I don't see a need to rebuild already built libraries, as long as you have permission to repackage them with your app and your app will dynamically link to them. If you did build them yourself you would know more about their dependencies though.
koan
Yeah, and I could probably get rid of some too. I'm looking at the libSDL that comes with WorldOfGoo and it has about 6 dependencies. The one that installs on Ubuntu however has about 10. Additionally, these libraries require on newer versions of libstdc++ and libc than are available on e.g. Debian lenny.
Noarth
A: 

The correct way to produce software for Linux is to put one tarball of source code per release in a stable location on your website, and let the distributions deal with everything else. Don't try to produce binaries yourself. You will save yourself from an unending supply of grief.

Zack
It's not open source. I guess that's the curse of proprietary software on Linux :)
Noarth
Well, the correct thing to do in that case is build proper, policy-compliant packages for every distribution you think your users are likely to want (I would do at least Fedora, Debian, and SuSE). The Skype folks do this and it works pretty well for end-users. It's a lot more work for you than source-only distribution ... but it's still less work than struggling with static linkage or dependency minimization.
Zack