[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

why can gcc find -lcrypt but not -lcfont (both in /lib)?



How can I find out exactly where gcc and ld look for libraries? 

The manual pages mention a default search mechanism, but never say exactly 
what that is, how it works (where it's configured on Linux or specifically 
Debian), or what the default search directories are.


The problem I'm having is that gcc seems to see some libraries in /lib and 
not others, and similarly sees some libraries in /usr/lib but not others.


For example, /lib contains both libcrypt and libctutils:

    -rw-r--r--    1 root     root        20112 Aug 14 18:11 /lib/libcrypt-2.1.3.so
    lrwxrwxrwx    1 root     root           17 Aug 14 18:11 /lib/libcrypt.so.1 -> libcrypt-2.1.3.so
    lrwxrwxrwx    1 root     root           19 Aug 14 18:11 /lib/libctutils.so.0 -> libctutils.so.0.0.0
    -rw-r--r--    1 root     root        18252 Aug 14 18:11 /lib/libctutils.so.0.0.0

but gcc can see libcrypt:

    $ gcc test.c -lcrypt    
    $

and not libctutils:

    $ gcc test.c -lctutils
    /usr/bin/ld: cannot find -lctutils
    collect2: ld returned 1 exit status
    $


Similarly, /usr/lib contains both libdb1 and libdb2:

    -rw-r--r--    1 root     root        80582 May  1 14:27 /usr/lib/libdb1.a
    lrwxrwxrwx    1 root     root           16 Aug 14 22:51 /usr/lib/libdb1.so -> /lib/libdb1.so.2
    lrwxrwxrwx    1 root     root           15 Aug 14 18:10 /usr/lib/libdb2.so.2 -> libdb2.so.2.7.7
    -rw-r--r--    1 root     root       278604 Aug 14 18:10 /usr/lib/libdb2.so.2.7.7

but gcc can see only libdb1 but not libdb2:

    $ gcc test.c -ldb1
    $ gcc test.c -ldb2
    /usr/bin/ld: cannot find -ldb2
    collect2: ld returned 1 exit status
    $ 


Any ideas?


(I've run ldconfig, but does that make any difference for compiling
and linking (vs. linking at load time)?)



Thanks,

Daniel
-- 
Daniel Barclay
dsb@smart.net
(Hmm.  A little worrisome:  http://www.junkbusters.com/cgi-bin/privacy
                            http://www.anonymizer.com/snoop.cgi )



Reply to: