Top Up Prev Next Bottom Contents Index Search

D.4 Architectural Dependencies


In this section, we discuss shared library architectural dependencies

Table 1:
Architecture Command(s) that prints what libraries a binary needs Library Path
Environment Variable
hppa chatr file SHLIB_PATH
irix5 elfdump -Dl file LD_LIBRARY_PATH
sol2 ldd file /usr/ccs/bin/dump -Lv file LD_LIBRARY_PATH
sun4 ldd file LD_LIBRARY_PATH
Commands to use to find out information about a binary or library

D.4.1 Solaris

Under Solaris the /usr/ccs/bin/dump -Lv file will tell you more shared library information about a binary. Under Solaris2, binaries compiled with shared libraries can have a path compiled that is used to search for shared libraries. This path is called the RPATH. The ld option -R is used to set this at compile time. Use /usr/ccs/bin/dump -Lv binary to view the RPATH for binary. The RPATH for a library can be set at the time of creation with the -L flag:

g++ -shared -L/users/ptolemy/lib.$PTARCH -o librx.so *.o
or by passing the -R flag to the linker:

g++ -shared -Wl,-R,/users/ptolemy/lib.$PTARCH -o librx.so *.o

Constructors and Destructors between SunOS4.x and Solaris2

The Solaris2 SPARCompiler c++4.0 Answerbook says

On SunOS 5.x, all static constructors and destructors are called from the .init and .fini sections respectively. All static constructors in a shared library linked to an application will be called before main() is executed. This behavior is slightly different from that on SunOS4.x where only the static constructors from library modules used by the application are called.

D.4.2 SunOS

The SunOS4.x port of Ptolemy uses BSD ld style linking, which will not work with a binary that is linked with any shared libraries. For incremental linking of stars to work, the ldd command must return statically linked when run on a SunOS4.x pigiRpc or ptcl binary.

ptolemy@mho 2% ldd ~ptolemy/bin.sun4/pigiRpc
/users/ptolemy/bin.sun4/pigiRpc: statically linked

D.4.3 HPUX

Under HPUX, shared libraries must be executable or they will not work. Also, for performance reasons, it is best if the shared libraries are not writable.

Under HPUX, shared libraries have a .sl suffix, and HPUX uses the SHLIB_PATH environment variable to search for libraries.

Under HPUX10, when you are building shared objects, you need to specify both -fPIC and -shared. (-fpic -shared will also work). The reason is that the temporary files that are generated by g++'s collect program need to be compiled with -fPIC or -fpic. Other platforms don't need both arguments present.



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.