Linux: How to statically link against system libs?

Alexander aldem+dmars at nk7.net
Thu Apr 28 17:46:16 PDT 2011


On 26.04.2011 21:44, Spacen Jasset wrote:

> On 26/04/2011 20:10, Steven Schveighoffer wrote:
> ...
>> I don't think static linking is officially supported any more.
> It is but only for OS binaries. Some systems infact, like AIX and Windows, do no support it at all.

  Windows does - there are static versions of C runtime and some others. Linux libc is not really very special, it only provides nice interface to syscalls.

  Actually, static linking is useful sometimes, and it is not always possible to link dynamically.

  Example: Fedora 14 and CentOS 5.5 shared libs are incompatible, though static binaries run on both - flawlessly. The main problem is that some dependencies are not satisfied through compatibility layer, as not all libs provide that (like libxml2 or
some other), thus, building on CentOS wouldn't really help (unless everything but libc will be linked statically anyway). Linux is now in "DLL hell" more than any Windows ever...

  And, by the way, D can be used for OS binaries as well ;) Though, I would look into direction of uClibc - smaller footprint and almost the same functionality, and it can be safely linked statically.

/Alexander


More information about the Digitalmars-d-learn mailing list