

How statically linked programs run on Linux - ptype
http://eli.thegreenplace.net/2012/08/13/how-statically-linked-programs-run-on-linux/

======
mickeyp
The interesting contrast here is how things are done on Windows.

The reason most C++ programs ran on all Windows computers (and with such a
tiny file size) is Windows shipped with the common libraries (C++ runtime)
required to run the programs.

When Borland came out with Delphi they wanted Microsoft to include some of
their own common libraries to reduce the footprint of the executable -- but
Microsoft said no, meaning Delphi's executables had to have everything linked
into it statically, resulting in files that were an order of magnitude bigger.
Aside from the stigma from larger file sizes in an era (the 90s) when this
mattered, they arguably came out ahead in this department as Delphi by default
avoided "DLL hell" (until MS solved it more or less definitively with Windows
2000) and would run anywhere, on anything, with no additional dependencies.

------
fiatmoney
Is it actually practical to statically compile & link large parts of a modern
C / C++ based software environment? The last time I tried to do that with a
nontrivial C program and GCC it felt like an ultimately unsuccessful snipe
hunt.

Incidentally, cross-compiling static binaries is a hugely productive feature
of Go.

~~~
nopaste7
Please see:

[http://www.akkadia.org/drepper/no_static_linking.html](http://www.akkadia.org/drepper/no_static_linking.html)

~~~
barrkel
There's only one minor problem; DLL hell. As long as none of your applications
break when you update their shared dependencies, everything's fine. The
package management system generally takes care of this in modern
distributions, and the package maintainers usually do enough coordination to
avoid (much) breakage.

But if you're trying to produce commercial shippable software (what used to be
called shrinkwrap), you're not going to fit in as easily with a package
management system. Your binaries will probably need updating when the shared
libraries update; that's a major headache. And this is one of the reasons why
there hasn't been much of a commercial market in software for Linux.
Everything generally works much more smoothly if your only dependencies are
glibc and a handful of other bits.

------
nemo1618
The suckless.org people (creators of dwm) are working on a fully static Linux
distro[1]. I'm quite interested to see how it turns out, but at this point
it's starting to look like vaporware.

[1]: [http://sta.li](http://sta.li)

------
Timmmmbob
TL;DR: Good luck! At least until recently it was virtually impossible to
actually do this - Autopackage used to have a list of things that prevented
making decently portable binary packages for Linux. I believe they resorted to
shipping a modified linker to get things to work.

Unfortunately there is a lot of hostility to making binary distribution easier
on Linux because of the "you should be using shared libraries and why would
you ever want to distribute binaries when you can just distribute the source
code?" attitude that prevails.

Having said that, GCC did finally add a _real_ option to link statically (i.e.
not `-static`) a few years ago. And I believe the linker finally supports
symbol versioning.

