From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078612210707.tru64-unix-managers.marc@archive.invalid> From: Ellen Davis Date: Thu, 29 May 1997 17:52:56 +0000 To: tru64-unix-managers Subject: SUMMARY: linking question X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078612210707 At 09:59 AM 5/27/97 -0400, you wrote: I posed a question about the order of libraries search when linking, in particular with use of the -L option. Thanks to Alex Garthwaite Jonathan Rozes Jonathan summed it up best: > >The search order is to go through the directory list and search for a >shared library, then go through the list again and search for a static >library. Thus, the linker is finding /usr/shlib/libdb.so before it finds >/usr/local/lib/libdb.a. You can fix this one of two ways: > >1. Specify the actual archive file instead of using the -l switch, as in > cc -o foo foo.c /usr/local/lib/libdb.a > >2. Pass the -oldstyle_liblookup flag to the linker, causing it to search > each directory once, first for the shared lib, then for the archive: > cc -o foo foo.c -L/usr/local/lib -Wl,-oldstyle_liblookup -ldb > Ellen Davis