Fog Creek Software
Discussion Board




Linux - static linking

  Just to stay in touch with the "latest and greatest", from time to time, I install one of the current Linux distros and play with it for a couple of days/weeks. Over the years I've seen a lot of changes, Linux on the desktop made a lot of progress from the first Slackware versions to the latest Mandrake.
  But one thing that puzzles me, why the Linux world sticks to the dynamic linking of libraries, making every software installation a hell for the inexperienced user? The second argument Linux entusiasts throw in (after instability) against Windows is dll hell. But just try to install (compile) any software that wasn't developed for the exact version and distro that you are using, and you'll see a dependency hell much worse than anything Windows can throw at you in it's worst days.
  The only two good examples for static linking that come to my mind are Mozilla (including Firefox and Thunderbird) and Opera. The size of the download is bigger, true, but you download a 10 mb archive, extract it to the location of you're choice and voila, they run whithout problems on any of the last year's ditros.
  Is it too much to ask from the Linux developers to make a statically linked, compiled version of their software, so the rest of us could start using Linux on an every day basis? Any thoughts?

Szász Attila
Friday, March 26, 2004

I can't speak for all Linux developers, but the culture in the Unix world is that you distribute source, and as long as "./configure ; make ; make install" works the developer is off the hook.

Binary installs are sort of a foreign implant form the land of Windows and Macintosh and commercial software.

Joel Spolsky
Fog Creek Software
Monday, March 29, 2004

I think there are two seperate problems labeled as DLL Hell.

1)  Dynamic Linking causing conflicts and random breakages
2)  Installations being a difficult 'dependency hunt'

The first problem is largely not an issue with linux.  All the dynamic libraries have a version, and you can have multiple versions of any given library installed.  So if FooBar 1.0 requires libBar 4.2, but you have 5.0 installed,  you can install 4.2 alongside it and not have any issues.  For instance GNOME 2.6's dependency on gtk-2.4 doesn't stop me from having 1.x and 2.2 installed.

The second problem is still difficult.  Programs like 'yum' and 'apt-get'  solve this brilliantly, however they still require far too much manual work for your average end user to work.  I've lost the link,  but a while ago the Fedora Core developers were talking about a solution which involved the following.

Provide a method to download 'package repository configuration' from the internet, probably as XML with a specific MIME type.  A helper application would then take this information, configure yum to use the repository and launch the 'system-config-packages' application with that repository's applications listed.  The user could then choose which packages to install, dependencies would be downloaded automagically and all would be fine.

By way of an example,  you would provide a FogBugz repository.  Your installation instructions would be:

1) Click here and choose to install FogBugz
2) Wait till the downloads are complete. 
3) You're done.

An additional benefit of this method is that all the updates you push out to the 'FogBugz yum repository' would automatically get picked up when they ran the 'update server' jobs.

I personally think that this is a *huge* improvement over the windows 'download then next next next' way of installing things.

Koz
Monday, March 29, 2004

I would like to see a linux distribution with something like the FreeBSD ports collection: http://www.freebsd.org/ports/

I use DarwinPorts on OS X.  The site says that it also supports linux though I have not tried: http://darwinports.opendarwin.org/

Oren Miller
Monday, March 29, 2004

Oren,

There is such a linux distro, Gentoo Linux. www.gentoo.org

Gentoo is a really great distro and while it takes a little bit of time to set up, using it really helps you learn the guts of linux.
The Gentoo ports collection is huge, with more software than the BSD ports tree.

Andrew Murray
Tuesday, March 30, 2004

The NetBSD ports system runs on Linux; I use it on machines at work and home.  See:

http://www.pkgsrc.org/

In fact, they've recently added experimental support for building on Interix/SFU, in case you'd like to use it on Windows.  :)

Phillip J. Eby
Tuesday, March 30, 2004

The obvious advantage to dynamic linking is that when a bug is found and patched in OpenSSL, for example, all installed software that is dynamically linked has the fix applied to them.  If you have statically linked software, you have to wait for each and every company to release a fix.  The other advantage, albeit a small one, is that you can reduce memory overhead if you are running lots of software that all use the same libraries as only one copy of the library needs to be loaded into memory.

I cannot recall the last time I had a problem with libraries.  That said, all but a couple of pieces of software I run on my Mandrake Linux system were packaged by Mandrake or by the penguin liberation front so I rarely encounter dependency issues.

Chris Thompson
Tuesday, March 30, 2004

Umm, have you looked at Mozilla? It's not statically linked (I just checked the Firefox download). It's very much dynamic. The reason it doesn't need a whole lot of dependencies is they've rolled most of their own stuff.

David M. Cooke
Wednesday, March 31, 2004

Library versioning is a HUGE problem on Linux. Or more accurately, maintainers that don't pay attention to versioning. Often libraries are changed in incompatible ways without changing the library name. Also, some "core" libraries are not forwards-compatible (glibc being the most important offender).

e.g. any program compiled against glibc 2.3 will not work on a system that only has glibc 2.2. That's as if any program compiled on Windows XP would not work on Windows 2000.

I'm a kernel developer and general Linux fan, but I agree that library/dependency versioning issues are a very serious impairment to the usability of Linux.

If you are interested in static linking, check out dietlibc. It's a very small/clean C library optimized for code size. Often static programs compiled with dietlibc are no larger than dynamic programs with glibc. (e.g. my sshd binary is 794KB, completely static with dietlibc)

Dan Maas
Thursday, April 01, 2004

Wait a second, the term 'DLL hell' applies when all DLLs supplied with different packages clash together. Linux has solved it the simplest possible way, putting the library version in the file name, that way you install all the versions of the files you need and there are no clashes.

Or rather, you really don't do anything about it, because the operating system does it all for you (the package manager). On Debian you just type 'apt-get install apache' and you'll get Apache the web server and all the other programs it requires. Normally you never care about the libraries.

The reasons for dynamic linking are mainly a) size, both on disk and in memory, as the libraries are loaded only once, and b) easier updates as you can apply security fixes just to the libraries. A drawback is that pure dynamic linking increases the startup time for apps, something very apparent in KDE. To remedy this, run a utility called 'prelink' after you installed it! (This is relatively new so most distributions don't do this by default. MacOSX does it by default.)

Jonas B.
Thursday, April 01, 2004

*  Recent Topics

*  Fog Creek Home