Re: static linking warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



burlen wrote:

> I am encountering a warning which I would like to understand a little
> better.
> 
> p4_secure.c: warning: Using 'getpwuid' in statically linked applications
> requires at runtime the shared libraries from the glibc version used for
> linking

This message actually is generated by glibc and not gcc; it's a library
thing not a compiler thing. 

> I am building an app with the --static flag. I have attempted to make
> sure that all of the components of this app are linked against
> statically linked libraries. This call is part of the underlying system.
> But why would I get this warning? Why wouldn't those functions be linked
> in statically as well?

Because of NSS.  To access the passwd database might require LDAP,
kerberos/hesioid, nscd, nis, ... who knows.  The exact configuration is
not known at the time the app is linked because it depends on how the
deployment machine happens to be configured.  Remember that the whole
point of NSS is to be a modular system, the purpose of which is to allow
pluggable modules to intercept and handle these functions.  There's no
way to compile in code for every possible scenario, they are meant to be
loaded at runtime.

And besides that, in general the policy of glibc tends to frown heavily
on static linking:
<http://people.redhat.com/drepper/no_static_linking.html>.

If you want universal deployment, dynamically link against an ancient
version of glibc.  The library is forward compatible due to symbol
versioning, so it will work on any newer system.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux