In Unix-speak, we categorize such problems as either compile-time, or link-time. This document describes the link-time solutions that I've seen over and over again. Larry Virden covers related territory in his post on linking advice. Simon Burr writes specifically about -R searching, with a slight Solaris bent.
... [Ref linking concepts; discovery; order; Unix]
[Explain that dynamic linking is not all it's cracked up to be.]
ldd
command is invaluable for diagnosing
references involving dynamically-linked libraries.
[explain prefix, LD_..., ...]
Your application appears to depend on an entry point, "SOME-SYSTEM-FUNCTION"; where will you find it? Here are the best ways:
LIST="/usr/lib/*.a /usr/lib/lib*.so*" for F in $LIST do echo "$F:" nm $F | grep SOME-SYSTEM-FUNCTION done
cc -o myprogram myprogram.o -lX11 -lmylibmight fail while
cc -o myprogram myprogram.o -lmylib -lX11gives happy results.
HP-UX shared libraries can be specified
-Wl,+s,+b,/usr/local/lib:.
"
on the command-line or in LDFLAGS
, or
SHLIB_PATH
.
/usr/local/lib
, for
example) with shared libraries. I've come across reports
that it sometimes helps to unsetenv LD_LIBRARY_PATH
when relying on SHLIB_PATH
.
Several [itemize ...] versions of
Tcl
[and other common tools--itemize ...]
implement a common error with HP-UX dynamic linking.
The source file tclLoadShl.c
includes the line
handle = shl_load(fileName, BIND_IMMEDIATE, 0L);rather than the correct
handle = shl_load(fileName, DYNAMIC_PATH | BIND_IMMEDIATE, 0L);Tcl-ers code around this at the script level by doing an absolute
load
[document ...] rather than package require
.
Examination of errno
after shl_findsym
sometimes is useful.
[Explain ldd.]
Some installations (Slackware 2.1? 3.1? others? Red Hat before 4.0?) are reputed to have a missing symbolic link between /lib/libdl.so.1 and /lib/libdl.so. Any application which employs dynamic linking, and which therefore links with "... -ldl ..." under Linux, apparently will fail until one completes the installation by commanding
ln -s /lib/libdl.so.1 /lib/libdl.soThat's the whole story that I know. However, those unfamiliar with Unix deserve a warning: the previous paragraph used "link" in three distinct senses. If these matters are new to you, you might feel more comfortable substituting
cp /lib/libdl.so.1 /lib/libdl.sofor the "ln ..." command above. When I'm able to make time, I'll return to explain these matters more fully.
Why isn't there a /lib/libdl.a
? That's an involved topic,
one that I aim to document later in spring '97.
ldconfig is sometimes an issue for Linux. I'll document it once I understand it better.