HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 69 (of 101)
Chapter 11 Software Development
October 29, 2013
The symbol is indeed missing: You checked all objects and libraries with nm(1) but
there were only references (undef).
Check if there is a library or an object missing in the link command. Use nm(1) to find it.
To find out if a symbol is in an HP-UX runtime library, you could also check if there is a
man page available for it. If there is one, it sometimes tells you which library must be
used. If the man page does not tell you, search all libraries under /usr/lib.
The reference is wrong: If the symbol is referenced by your own code, check if there is
a typo. Most compilers would report an undefined symbol error or warning in that case,
but e.g. the cc_bundled doesn't care for undefined symbols, cc might issue a warning
about a missing prototype.
Incorrect link order: This can happen especially with archive libraries. The linker
processes the objects and libraries in the order they are listed at the command line. If you
have an object in an archive lib, then the linker will not load it if there was no reference
to any of its symbols at that time. Later references will then lead to unsatisfied symbol
problems. Make sure that there is at least one reference to a symbol of that object, before
it is loaded.
Version conflict: Often runtime libraries depend on each other, and if a change is
introduced to one by applying a patch, another one might need to be patched too. So it
sometimes could also help to check for new versions of system libraries like libc, libcl,
aC++ runtime libraries etc.
Unsatisfied Symbols (Special Cases)
While the previous paragraph gave a general approach to find reasons for unsatisfied symbols,
there are several common cases where the general approach would be too complicated.
/usr/ccs/bin/ld: Unsatisfied symbols:
_main (first referenced in x.o) (code)
If you find _main unsatisfied, this could be caused by aC++ objects that are not linked with aCC.
It is strongly recommended to use aCC to call the linker, because aC++ programs need several
additional linker options which are added automatically by aCC.
/usr/ccs/bin/ld: Unsatisfied symbols:
std::ios_base::Init::Init() (first referenced in x.o) (code)
std::ios_base::_C_fire_event(std::ios_base::event,bool) (first
referenced in x.o) (code)
:
If the linker reports several unsatisfied symbols that start with std::, this is caused by aC++
code that was compiled with the -AA option of aC++. This switches on the ANSI compatible
mode. If however -AA was not present at link time, aCC will link the program against the non-
ANSI runtime libs. The solution here is to compile and link everything with the -AA option.