Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my static build require shared libraries?

Tags:

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

like image 639
Crazy Chenz Avatar asked Jul 07 '09 13:07

Crazy Chenz


People also ask

Why do we need shared libraries in addition to static ones?

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.

What is static shared library?

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.

When use static library vs shared library?

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.

What is the difference between static and shared library in IIB?

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.


1 Answers

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

like image 199
nos Avatar answered Oct 06 '22 04:10

nos