Why does my static build require shared libraries?
Every so often I get these warnings from my linker... (at the moment it is happening with openssh-5.2p1)
The warnings look similar to: "Using 'function' in statically linked applications requires at runtime the shared libraries from the glibc version used for..."
When I google, I only see fixes, not reasons.
Thanks, Chenz
The most significant advantage of shared libraries is that there is only one copy of code loaded in memory, no matter how many processes are using the library. For static libraries each process gets its own copy of the code.
Static libraries, while reusable in multiple programs, are locked into a program at compile time. Dynamic, or shared libraries, on the other hand, exist as separate files outside of the executable file.
Static libraries take longer to execute, because loading into the memory happens every time while executing. While Shared libraries are faster because shared library code is already in the memory. In Static library no compatibility issue has been observed.
If a shared library is deployed in a BAR file, it can still be used by applications or shared libraries in other deployed BAR files. Static libraries are packaged and deployed in the same BAR file as the applications that reference them.
It doesn't require shared libs per se, it just warns you that some things might not work properly if you link statically to glibc.
Some of those things are the nsswitch, see e.g. /etc/nsswitch.conf
.On a system different ways of looking up users/groups/hostnames and other things can be configured and altered via plugins - e.g. samba comes with a module for managing users configured on a windows domain/active directory transparently.
Your app will not honor /etc/nsswitch.conf
customization if you link statically to glibc, functions such as gethostbyname
,getpwuid
and others will just use the default ways of looking up things.
Same goes for e.g. other libraries your app might use that for whatever reason dlopen()s
itself to hook into glibc or similar.
See also
Statically linking considered harmful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With