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

Checking for run-time compatibility

Suppose you have been supplied with an updated version of a dynamically linked library. 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 dynamically linked library 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 dynamically linked library 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 dynamically linked 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 pathnames of the dynamically linked library 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 is not 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: Specifying directories to be searched by the dynamic linker

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