Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifying which Linux system library contains a function

I am using a dev system where I have to specify the lib name when accessing a function inside it.

I've used functions like open() before, and somehow found out that they're in libc.so.

Now I want to use lstat(), but it appears that this one is not in libc. Sadly, the man pages I looked at do not document the location of the functions.

So, two questions:

  1. Can someone tell which lib hosts lstat?
  2. How can I generally find this out? Other than using grep "name" on all files in the lib folder, I mean.
like image 664
Thomas Tempelmann Avatar asked Feb 24 '10 14:02

Thomas Tempelmann


People also ask

How do I find libraries in Linux?

By default, libraries are located in /usr/local/lib, /usr/local/lib64, /usr/lib and /usr/lib64; system startup libraries are in /lib and /lib64. Programmers can, however, install libraries in custom locations. The library path can be defined in /etc/ld.

What are system calls and library functions in terms of Unix commands?

A system call is a function provided by the kernel to enter into the kernel mode to access the hardware resources. A Library call is a function provided by the programming library to perform a task. 6. System call are the entry points of the kernel, and therefore they are not linked to the program.

What is the Linux system library?

System Library − System libraries are special functions or programs using which application programs or system utilities accesses Kernel's features. These libraries implement most of the functionalities of the operating system and do not requires kernel module's code access rights.

How do I check if a library is installed Linux?

In terms of commands, we may use the ldd command to find out missing dependencies. Also, we can use the ldconfig command with the -p option to check if a shared library is installed. Finally, we should check the standard library paths like /usr/lib and /usr/local/lib as well as extra paths listed in the /etc/ld.


1 Answers

Build a simple testcase in C, compile it and run 'ldd -r' on it to check what libs are loaded. If you don't get lstat() in C then you have a problem on your dev env. Or this env dates back before the age of symlinks :-)

like image 158
bernard Avatar answered Oct 13 '22 09:10

bernard