DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Shared libraries

Building an a.out file

The standard (non-shared) C library is still available with releases of the C Programming Language Utilities; this library is searched by default during the compilation or link editing of C programs.

To build a.out files, a shared library's name must be directly referenced by using the -l option with the C compiler. You direct the link editor to search a shared library the same way you direct a search of any library on the UNIX system:

cc file.c -o file ... -l library_file ...

To direct a search of the networking library, for example, you use the following command line.

cc file.c -o file ... -l nsl_s ...

And to link all the files in your current directory together with the shared C library you'd use the following command line:

cc *.c -lc_s

Including the -lc_s argument after all other -l arguments on a command line, indicates that the shared C library will be treated like the relocatable C library, which is searched by default after all other libraries specified on a command line.

A shared library might be built with references to other shared libraries. That is, the first shared library might contain references to symbols that are resolved in a second shared library.

For example, if the shared library libX_s.a references symbols in the shared C library, the command line would be as follows:

cc *.c -lX_s -lc_s

Notice that the shared library containing the references to symbols must be listed on the command line before the shared library needed to resolve those references. For more information on inter-library dependencies, see ``Referencing symbols in a shared library from another shared library''.


Next topic: Deciding whether to use a shared library
Previous topic: Shared libraries examples

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003