DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C and C++ compilation system

Checking for run-time compatibility

Suppose you have been supplied with an updated version of a shared object. You have already compiled your program with the previous version; the link editor has checked it for undefined symbols, found none, and created an executable. Therefore, you should not have to link your program again. The dynamic linker will simply use the definitions in the new version of the shared object to satisfy unresolved external references in the executable.

Suppose further that this is a database update program that takes several days to run. You want to be sure that your program does not fail in a critical section because a symbol that was defined by the previous version of the shared object is no longer defined by the new version. You want the information that the link editor gives you -- that your executable is compatible with the shared library -- without having to link edit it again.

There are two ways you can check for run-time compatibility. The command ldd (``list dynamic dependencies'') directs the dynamic linker to print the path names of the shared objects on which your program depends:

   $ ldd prog
When you specify the -d option to ldd, the dynamic linker prints a diagnostic message for each unresolved data reference it would encounter if prog were executed. When you specify the -r option, it prints a diagnostic message for each unresolved data or function reference it would encounter if prog were executed.

You can do the same thing when you execute your program. Whereas the dynamic linker resolves data references immediately at run time, it normally delays resolving function references until a function is invoked for the first time. Normally, then, the lack of a definition for a function will not be apparent until the function is invoked. By setting the environment variable LD_BIND_NOW

   $ LD_BIND_NOW=1 export LD_BIND_NOW
before you execute your program, you direct the dynamic linker to resolve all references immediately. In that way, you can learn before execution of main begins that the functions invoked by your process actually are defined.
Next topic: Dynamic linking programming interface
Previous topic: Handling multiply defined symbols

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005