From: Subject: Using static and shared libraries across platforms Date: Wed, 17 Apr 2002 16:03:47 +0200 MIME-Version: 1.0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Location: http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Using static and shared libraries across = platforms

Using static and shared libraries across platforms

I = produced=20 hereafter some information about shared libraries on different systems. = However,=20 this information is probably very sparse on details and may even not be=20 up-to-date. Actually, keeping track of changes is nearly impossible. =
The=20 definitive information usually comes from the operating system docs. = (e.g. HP's=20 "HP-UX Linker and Libraries User's Guide", Sun's "Linker and Libraries = Guide",=20 SGI's"MIPSpro Compiling and Performance Tuning Guide", IBM's AIX Linking = and Loading=20 Mechanisms, etc.), where there is often advice on the best options = for=20 performance.
As far as C++ is concerned, details can get hairy = especially=20 due to templates. ORBacus is an=20 implementation of CORBA written in C++. The file runconfig = within=20 its distribution provides a lot of up-to-date information.=20

Feedback= is=20 welcome.


Adapted from:
Cross platform development, Using Shared Libraries = across=20 Platforms, Shah, Amal ; Xiao, Hong, C/C++=20 Users Journal, May=20 1998, Volume 16 Number 5=20

Shared and static libraries information
Linux
[kernel 2.x, GCC 2.95.x and later]
Solaris=20
[2.8]
HP-UX
[11]
Compaq = (Digital)=20
[4.x]
AIX =
[4.3 and later]
SGI
[Irix 6.5]
Win32
[NT 4]
MacOS = X
[10.x]
VMS =
[unmaintained]
OS/390
[unmaintained]
1
compile = flags=20 -fPIC -KPIC, = -Kpic +z/+Z xxxx xxxx -KPIC = (default)=20 xxxx -fno-common xxxx -DLL
2a
library = creation=20 flags -shared -G = -b = -shared -bM:SRE -shared /DLL cc = -bundle,=20 -dynamiclib
libtool -dynamic =
/SHARE xxxx
2b
archiver = (C++)=20 c++ -fPIC = -shared=20 -o CC -G = -o aCC -b = -o cxx = -shared -o=20 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=20 ?? = ?? =
libtool -static
?? = ?? =
2c
static = archiver=20 (c++) ar = CC -xar = -o ar = ar = ar = CC -ar = -o ?? = ?? =
libtool -static
?? = ?? =
3a
library = name (ld = option) -soname=20 name -h = name (ld = option) +h=20 name (ld = option) -soname=20 name xxxx (ld = option) -soname=20 name /OUT:name -compatibility_version,=20 -current_version /SHARE=3D xxxx
3b
file = extension=20 .so .so .sl .so = .so (or = .a) .so .DLL .dylib ?? = ?? =
4
executable link=20 options -Bdynamic=20
-Lpath -lname
-Bdynamic=20
-Lpath -lname
-a,shared=20
-Lpath -name
-no_archive=20
-Lpath -lname
-brtl
-bdynamic
-Lpath = -lname
-Bdynamic,=20
-Lpath -lname
xxxx ??=20 xxxx filename/SHAREABLE
5a
runtime = path=20 specification -rpath=20 <path> -R=20 <pathlist> -Wl,+b = <pathlist>=20 -Wl,+s -rpath=20 <path> -blibpath:<path>
(by = default, it is=20 set to the arguments of -L)
-rpath=20 <path> /LIBPATH: -install_name xxxx xxxx
5b
Does not = build the path=20 for shared libraries into the executable default -norunpath chatr +b = disable=20 <file> default -blibpath:/usr/lib:/lib default ?? = ?? = ?? = ?? =
6
controlling=20 symbols using a = script file=20 (see "info ld") -z defs/ = nodefs/=20 muldefs +v[no]=20 shlibunsats -expect = [error]=20 _unresolved xxxx -ignore[no]=20 _unresolved /FORCE: = MULTIPLE=20 [UNRESOLVED] ?? = xxxx xxxx
7
exports = file/link=20 option using a = script file=20 (see "info ld") using a = script file=20 (see "man ld") +e,symname -exported_symbol=20 .exp -exported_symbol=20
-exports_file filename
.def/__declspec(dllexport) ?? = /SYMBOL_TABLE=3D(...) .x = file/=20
#pragma export()
8
hiding = symbols=20 using a = script file:=20 VERSION command (see "info ld") using a = script file=20 (see "man ld") -h = symname -hidden_symbol,=20 -hidden xxxx -hidden_symbol,=20
-hiddens_file filename
xxxx ?? = xxxx xxxx
9
runtime = library=20 path LD_LIBRARY_PATH=20 LD_LIBRARY_PATH=20
LD_LIBRARY_PATH_64
SHLIB_PATH=20
LD_LIBRARY_PATH (64 bits)
LD_LIBRARY_PATH=20 LIBPATH LD_LIBRARY_PATH=20
LD_LIBRARYN32_PATH
LD_LIBRARYN64_PATH
PATH DYLD_LIBRARY_PATH=20
DYLD_FALLBACK_LIBRARY_PATH
SYS$SHARE LIBPATH
10
symbol = binding=20 -Bsymbolic -Bsymbolic -Bsymbolic /immediate=20 /deferred xxxx xxxx -Bsymbolic xxxx ?? = xxxx xxxx
11
runtime=20 debugging (c.f. = man=20 ld.so)
LD_BIND_NOW =
LD_TRACE_LOADED_OBJECTS
LD_DEBUG=3Dhelp= =20
ltrace
(c.f.=20 man ld.so.1)
LD_BIND_NOW=20
LD_DEBUG
ld -D = help
(c.f. = man=20 dld.sl)
_HP_DLDOPTS
(c.f. = man=20 loader)
LD_BIND_NOW =
_RLD_ARGS
LDR_CNTRL (c.f. = man=20 rld)
LD_BIND_NOW =
_RLD_PATH, _RLD_ARGS
xxxx DYLD_BIND_AT_LAUNCH
DYLD_PRINT_LIBRARIES
DYLD_PREBIND_DEBUG
xxxx xxxx
12
runtime = preload=20 LD_PRELOAD LD_PRELOAD xxxx _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=20 performance xxxx xxxx fastbind = tool=20 -quickstart_info=20 xxxx -quickstart_info=20 xxxx xxxx xxxx xxxx
15
versioning using a = script file:=20 VERSION command (see "info ld") using a = script file=20 (see "man ld")
-M mapfile
xxxx xxxx xxxx -set_version/-exact_version/
-ignore_version
/VERSION:major.minor ?? = /GSMATCH=3D xxxx
16
entry = points xxxx xxxx xxxx xxxx xxxx xxxx DllMain xxxx xxxx xxxx
17
dynamic = loading=20 /
dynamic symbol access
dlopen / = dlsym=20 dlopen / = dlsym=20 shl_load = /=20 shl_findsym
(64 bits) dlopen / = dlsym
dlopen / = dlsym=20 loadquery/loadbind
(AIX 4.2) = dlopen /=20 dlsym
dlopen / = dlsym=20 LoadLibrary /=20 GetProcAddress "man 3 = dyld" lib$find_image_symbol dllload / = dllqueryfn/=20 dllqueryvar
18
utilities ldd, = ldconfig, objdump,=20 ltrace ldd, = elfdump, pvs,=20 dumpstabs (compilers V.6) chatr
odump
ldd, elfdump (HP-UX = >=3D=20 11)
odump = -Dl dump = -H
ldd (in AIX = tools)=20
elfdump = -Dl=20
pldd=20
ldd (IRIX >=3D 6.5)
DUMPBIN, = depends,=20 EXEHDR otool ANALYSE/IMAGE xxxx
19
documentation=20 man: ld, = ld.so,=20 ldd
info: ld, gcc, binutil =
HOWTO: ELF-HOWTO, GCC-HOWTO
man: ld, = ld.so.1, ldd,=20 pvs man: ld, = dld.sl,=20 chatr man: ld, = loader,=20 odump man: ld, = dump man: dso, = ld, rld,=20 elfdump, ldd ?? = man: ld, = libtool, dyld,=20 otool ?? = ?? =
Linux Solaris HP-UX Compaq = (Digital)=20 AIX = SGI Win32 MacOS = X VMS =
[unmaintained]
OS/390
[unmaintained]
Note: = cells with=20 xxxx implies that the OS does not support that particular = feature.=20 ?? means I don't know.=20


Acknowledgments

Juan Altmayer = Pizzorno, Per=20 Losenborg, Andrew Stalewski, Nathan Stratton Treadway=20
$Id: sharedlib.html,v 1.15 2002/01/31 15:04:10 arnaud Exp $=20
by Arnaud=20 Desitter.
=A9 Arnaud Desitter, 1999, 2002
=A9 The Numerical Algorithms Group Ltd, = Oxford UK.=20 1999, 2002