如何通过库名找到库的文件名? [英] How to I find the filename of a library via the library name?
问题描述
如何通过库名找到库的文件名?
How to I find the filename of a library via the library name?
换句话说,当我使用"-lc"时,我知道它是/lib/libc.so.6(或类似名称.)我希望能够键入一些命令,其中"-lc"是输入,输出为"/lib/libc.so.6".为了进一步扩展这个想法,我想指定自己的搜索路径,以便可以将此库解析器用于不同的工具链...任何帮助都很棒,
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,
谢谢 钦茨
推荐答案
如果要找出给定的GCC在哪里可以找到libc.a或libc.so,请执行以下操作:
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
-lc
转换为libc.so.6
的原因有些复杂:对于glibc,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 ) )
或类似的东西.
这篇关于如何通过库名找到库的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!