How to I find the filename of a library via the library name?
Asked Answered
I

2

11

How to I find the filename of a library via the library name?

In otherwords, when I use "-lc", I know it is /lib/libc.so.6 (or something similar.) I want to be able to type some command where "-lc" is the input and "/lib/libc.so.6" is the output. To extend this idea futher, I wanted to specify my own search path so I can use this library resolver for different toolchains... Any help would be awesome,

Thanks Chenz

Integration answered 23/10, 2009 at 17:10 Comment(0)
T
13

If you want to find out where a given GCC will find libc.a or libc.so, do this:

gcc --print-file-name=libc.a
gcc --print-file-name=libc.so

The reason -lc translates into libc.so.6 is somewhat complicated: for glibc, libc.so is a linker script, which usually contains:

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-i386)
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux.so.2 ) )

or something similar.

Tarrasa answered 24/10, 2009 at 4:18 Comment(1)
This command is not working for user libraries, even though i have added local library path in $LD_LIBRARY_PATH.Tita
S
5

gcc -Wl,--trace file.c

will print list of input files for ld

Sensate answered 23/10, 2009 at 17:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.