Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list exported functions in a shared lib on Ubuntu

Tags:

c++

ubuntu

linker

I have just built a shared lib on Ubuntu, and when I attempt to use the function, the application that loads the library is reporting 'xxx' symbol not found.

I want to check (i.e. list) the functions that are exported by my library so I can investigate this issue further.

Relevant details:

OS: Ubuntu 9.10 compiler: gcc 4.4.1 linker: GNU ld 2.20

like image 442
Stick it to THE MAN Avatar asked Feb 16 '10 16:02

Stick it to THE MAN


People also ask

How do I find exported symbols in Linux?

We can use the readelf command with the -s flag to view exported symbols: $ readelf -s lib.so Symbol table '.

How do I find the symbol in an .so file?

The flag -g is used to show only exported symbols. Show activity on this post. Try adding -l to the nm flags in order to get the source of each symbol. If the library is compiled with debugging info (gcc -g) this should be the source file and line number.

How do I view the contents of libraries in Linux?

In Linux, to check whether a routine exists within a library file, use the nm command with the -g option, and pipe the output to grep .

Where is shared library Ubuntu?

Shared libraries are compiled code which is intended to be shared among several different programs. They are distributed as . so files in /usr/lib/. A library exports symbols which are the compiled versions of functions, classes and variables.


1 Answers

Try the nm utility.

GNU nm lists the symbols from object files objfile.... If no object files are listed as arguments, nm assumes the file a.out. [reference]

like image 135
rpg Avatar answered Sep 23 '22 00:09

rpg