views:

88

answers:

1

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

+2  A: 

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

nos