I am sorry people, for asking the FAQ covered question :), seems I just
overlooked this detail, when checked the paper last time. I am posting
the summary however, not to break this list etiquette.
(thanks to Casper Dik for pointing me out to this document:
<http://www.wins.uva.nl/pub/solaris/solaris2/>)
The solaris FAQ says:
6.24) I have problems linking my application statically.
In Solaris 2.x static linking is not supported for any of the
system libraries. All the functions that use /etc/nsswitch.conf
(getXXXbyYYY, getpwXXX, etc) require the dynamic linker to
load the code to load these functions. It is not possible
to write configurable/extensible functions in such a way that
dynamic linking is not required. E.g., you can add your own
nsswitch.conf backend which would not be known to programs
statically linked to only the standard backend code.
Programs that link statically against any of the OS libraries
may not run in the next release and are not ABI compliant.
Programs that link statically don't get some dynamic performance
enhancements found in the shared libraries: using hardware
multiply/divide on systems that support it; using fast mem*()
operations on UltraSPARC etc. And you won't pick up performance
enhancements in next releases: e.g., Solaris 2.5 comes with
a 4x faster fread/fwrite and the "Name Server Cache Daemon".
If you don't care about ABI compliance, i.e., you won't
ship your program as a product and don't care that you may
need to recompile after an OS upgrade, here are some of your
options:
Link statically against all but libdl:
cc -Bstatic .... -Bdynamic -ldl -Bstatic
Link against dl* stubs (gethostbyXXX, getpwXXX etc won't work any
longer):
char *dlopen() { return 0;}
int dlclose() { return 0;}
char *dlsym() { return 0;}
char *dlerror() { return "dynamic linking not loaded";}
If you don't want any dependencies on /usr, link against the dynamic
libs in /etc/lib:
cc -Bstatic ... -Bdynamic -R/etc/lib -Wl,-I/etc/lib/ld.so.1 -ldl
-Bstatic ....
If you still get undefined symbols, check with ldd for all your
libraries if they have any dynamic dependencies. E.g.,
% ldd /usr/lib/libsocket.so.1
libnsl.so.1 => /usr/lib/libnsl.so.1
libdl.so.1 => /usr/lib/libdl.so.1
libc.so.1 => /usr/lib/libc.so.1
libintl.so.1 => /usr/lib/libintl.so.1
libw.so.1 => /usr/lib/libw.so.1
tells you that if you want to link libsocket statically,
you need to link with -lnsl -ldl -lc -lintl and -lw as well.
--- end of excerpt from the FAQ
Questions marked with a * or + have been changed or added since
the FAQ was last posted
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:13:14 CDT