How to list exported functions in a shared lib on Ubuntu
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
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]
nm -D -C -g <library>
works well too.
Is your shared library in the library load path or in the application's run-time search path? It sounds like the dynamic linker can't find your library. Try running ldd
on your application to see if the library can be found at run-time, e.g.:
$ ldd /usr/bin/less
linux-gate.so.1 => (0x0072a000)
libncurses.so.5 => /lib/libncurses.so.5 (0x00c68000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x007c7000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0x00286000)
/lib/ld-linux.so.2 (0x002a1000)
See the ld.so(8) man page for additional details on library search paths.
精彩评论