I produced hereafter some information about shared libraries on different
systems. However, this information is probably very sparse on details and may
even not be up-to-date. Actually, keeping track of changes is nearly
impossible.
The definitive information usually comes from the operating system docs.
(e.g. HP's "HP-UX Linker and Libraries User's Guide", Sun's
"Linker and Libraries Guide", SGI's "MIPSpro Compiling and
Performance Tuning Guide", IBM's "AIX Linking and Loading
Mechanisms", etc.), where there is often advice on the best options
for performance.
GNU libtool offers an
abstraction layer to shared library management.
Feedback is welcome.
Adapted from:
Cross platform development, Using Shared Libraries across
Platforms, Shah, Amal ; Xiao, Hong, C/C++ Users Journal, May 1998, Volume 16 Number 5
Linux | Solaris | HP-UX | Compaq (Digital) Tru64 | AIX | SGI | Win32 | MacOS X | VMS | OS/390 | ||
---|---|---|---|---|---|---|---|---|---|---|---|
Version | [kernel 2.x, GCC 2.95.x and later] | [2.8] | [11] | [4.x] | [4.3 and later] | [Irix 6.5] | [NT 4] | [10.x] | [unmaintained] | [unmaintained] | |
1 | compiler flag (position independent code) | -fPIC | -KPIC, -Kpic | +z/+Z | xxxx | xxxx | -KPIC (default) | xxxx | -fno-common | xxxx | -DLL |
2a | shared library creation flag | -shared | -G | -b | -shared | -bM:SRE | -shared | link /DLL | cc -bundle, -dynamiclib libtool -dynamic |
/SHARE | xxxx |
2b | shared library creation (C++) | g++ -fPIC -shared -o | CC -G -o | aCC -b -o | cxx -shared -o | xlC -G (or -qmkshrobj) obsolete:/usr/vacpp/bin/makeC++SharedLib -G -o (was in /usr/ibmcxx/bin or /usr/lpp/xlC/bin/) |
CC -shared -o | CL -LD -Fexxx.DLL | ?? libtool -dynamic |
?? | ?? |
2c | static archiver (C++) | ar | CC -xar -o | ar | ar | ar | CC -ar -o | LIB (avoid link /lib that creates __impl symbols) | ?? libtool -static |
?? | ?? |
3a | library name | (ld option) -soname name | -h name | (ld option) +h name | (ld option) -soname name | xxxx | (ld option) -soname name | /OUT:name | -compatibility_version, -current_version | /SHARE= | xxxx |
3b | file extension | .so | .so | .sl | .so | .so (or .a) | .so | .DLL | .dylib | .EXE | ?? |
4 | executable link options | -Bdynamic -Lpath -lname |
-Bdynamic -Lpath -lname |
-a,shared -Lpath -name |
-no_archive -Lpath -lname |
-brtl -bdynamic -Lpath -lname |
-Bdynamic, -Lpath -lname |
Controlled by .lib files | ?? | xxxx | filename/SHAREABLE |
5a | runtime path specification | -rpath <path> | -R <pathlist> | -Wl,+b <pathlist> -Wl,+s | -rpath <path> | -blibpath:<path> (by default, it is set to the arguments of -L) |
-rpath <path> | /LIBPATH: | -install_name <path> | xxxx | xxxx |
5b | Does not build the path for shared libraries into the executable | default | -norunpath | chatr +b disable <file> | default | -blibpath:/usr/lib:/lib | default | ?? | ?? | ?? | ?? |
6 | controlling symbols | using a script file (see "info ld") | -z defs/ nodefs/ muldefs | +v[no] shlibunsats | -expect [error] _unresolved | xxxx | -ignore[no] _unresolved | /FORCE: MULTIPLE [UNRESOLVED] | ?? | xxxx | xxxx |
Linux | Solaris | HP-UX | Compaq (Digital) Tru64 | AIX | SGI | Win32 | MacOS X | VMS | OS/390 | ||
7 | exports file/link option (see notes) |
using a script file (see "info ld") | using a script file (see "man ld") | +e,symname | -exported_symbol | .exp | -exported_symbol -exports_file filename |
.def/__declspec(dllexport) | -exported_symbols_list | /SYMBOL_TABLE=(...) | .x file/ #pragma export() |
8 | hiding symbols | using a script file: VERSION command (see "Version Script" section in "info ld") | using a script file (see "man ld") (see this article) | -h symname | -hidden_symbol, -hidden | xxxx | -hidden_symbol, -hiddens_file filename |
using a .def file | -unexported_symbols_list | xxxx | xxxx |
9 | runtime library path | LD_LIBRARY_PATH | LD_LIBRARY_PATH LD_LIBRARY_PATH_64 |
SHLIB_PATH LD_LIBRARY_PATH (64 bits) |
LD_LIBRARY_PATH | LIBPATH | LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARY64_PATH |
. and then PATH | DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH |
SYS$SHARE | LIBPATH |
10 | symbol binding | -Bsymbolic | -Bsymbolic | -Bsymbolic /immediate /deferred | xxxx | xxxx | -Bsymbolic | xxxx | ?? | xxxx | xxxx |
11 | runtime debugging | (c.f. man ld.so) LD_BIND_NOW LD_TRACE_LOADED_OBJECTS LD_DEBUG=help ltrace |
(c.f. man ld.so.1) LD_BIND_NOW LD_DEBUG ld -D help |
(c.f. man dld.sl) _HP_DLDOPTS |
(c.f. man loader) LD_BIND_NOW _RLD_ARGS |
LDR_CNTRL | (c.f. man rld) LD_BIND_NOW _RLD_PATH, _RLD_ARGS |
xxxx | DYLD_BIND_AT_LAUNCH DYLD_PRINT_LIBRARIES DYLD_PREBIND_DEBUG |
xxxx | xxxx |
12 | runtime preload | LD_PRELOAD | LD_PRELOAD | LD_PRELOAD (probably HP-UX >= 11) | _RLD_LIST "xxx.so:DEFAULT" | xxxx | _RLD_LIST "xxx.so:DEFAULT" | ?? | DYLD_INSERT_LIBRARIES | ?? | ?? |
13 | loader | ld.so | ld.so | dld.sl | loader | xxxx | rld | xxxx | dyld | xxxx | xxxx |
14 | runtime performance | xxxx | xxxx | fastbind tool | -quickstart_info | xxxx | -quickstart_info | /DELAYLOAD | xxxx | xxxx | xxxx |
Linux | Solaris | HP-UX | Compaq (Digital) Tru64 | AIX | SGI | Win32 | MacOS X | VMS | OS/390 | ||
15 | versioning | using a script file: VERSION command (see "info ld") | using a script file (see "man ld") -M mapfile |
xxxx | xxxx | xxxx | -set_version/-exact_version/ -ignore_version |
/VERSION:major.minor | ?? | /GSMATCH= | xxxx |
16 | entry points | xxxx | xxxx | xxxx | xxxx | xxxx | xxxx | DllMain | xxxx | xxxx | xxxx |
17 | dynamic loading / dynamic symbol access |
dlopen / dlsym | dlopen / dlsym | shl_load / shl_findsym (64 bits) dlopen / dlsym |
dlopen / dlsym | loadquery/loadbind (AIX 4.2) dlopen / dlsym |
dlopen / dlsym | LoadLibrary / GetProcAddress | "man 3 dyld" | lib$find_image_symbol | dllload / dllqueryfn/ dllqueryvar |
18 | utilities | ldd, ldconfig, objdump, ltrace, readelf | ldd, elfdump, pvs, dumpstabs (compilers V.6), crle (Solaris>=8) | chatr odump ldd, elfdump (HP-UX >= 11) |
odump -Dl | dump -H ldd (in AIX tools) |
elfdump -Dl pldd ldd (IRIX >= 6.5) |
DUMPBIN, depends, EXEHDR, link -dump | otool | ANALYSE/IMAGE | xxxx |
19 | documentation | man: ld, ld.so, ldd info: ld, gcc, binutil HOWTO: ELF-HOWTO, GCC-HOWTO |
man: ld, ld.so.1, ldd, pvs | man: ld, dld.sl, chatr | man: ld, loader, odump | man: ld, dump | man: dso, ld, rld, elfdump, ldd | MSDN | man: ld, libtool, dyld, otool | ?? | ?? |
Linux | Solaris | HP-UX | Compaq (Digital) Tru64 | AIX | SGI | Win32 | MacOS X | VMS | OS/390 |
Notes:
"__attribute__((visibility("hidden")))"
for ELF targets.Juan Altmayer Pizzorno, Wolfgang Haefelinger, Per Losenborg, Anil E. Sahukar, Andrew Stalewski, Pirasenna Velandai Thiyagarajan, Nathan Stratton Treadway, Stephan Weber, Bo Xie
$Id: sharedlib.html,v 1.68 2007/06/15 16:05:49 adesitter Exp $ | Valid XHTML and CSS
by Arnaud Desitter.