How to view library files for Linux functions

Source: Internet
Author: User
Tags htons

refer:http://bbs.csdn.net/topics/330158874
view dynamic Library files for elf files: ldd < file name > dynamic library file

You can extract a lot of functions if you have enough time to extract the associated static libraries linked to the GCC compiler when using AR. In contrast to the function in your *.h. Find out who belongs to WHO.

when I encounter a function that does not know which library it belongs to, I will first look for the package to which the header file belongs, and then look at the. A or. so file for that package (or the related package), and then:
objdump-x Library File | grep function name

1, man htons, the inside is talking about arpa/inet.h;
2. Suppose you are using an RPM type system: Rpm-qa--filesbypkg | grep arpa/inet.h, you see one or several packages providing this file, and now I see Glibc-headers (RHEL5)
3, it seems that this glibc-headers is just a package containing header files, to see what other similar packages are: Rpm-qa | grep glibc
4, I saw the Glibc,glibc-devel,glibc-common, I think Glibc-devel is certainly to provide. A (static link)
5, Rpm-q--filesbypkg glibc-devel| grep \.a$ | awk ' {print $} ' |xargs grep htons find all static library files with htons
6. Only one:/USR/LIB/LIBC.A
7, if there are several words, use objdump-x to look at the symbol table

To say a few words-on the Debian type of machine with dpkg or apt-files is a similar process, sometimes need some common sense or speculation, such as *-devel package is to provide header files and static link library, the corresponding non--devel package is provided. So.


If you want to find a shared library that is loaded by a running process, you can use the PLDD command, which shows all the shared objects that were loaded into a process at run time. sudo pldd <PID>
Alternatively, you can choose a command-line tool called Pmap.  It reports the memory mapping of a process and also shows the library file dependencies of the running process. sudo pmap <PID>

How to view library files for Linux functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.