tags:

views:

635

answers:

2

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

+3  A: 

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]

rpg
**nm -C --defined-only -g libXXX.so** for C++
Nikolai N Fetissov
Thanks for that. It appears my symbol is exported, but undefined (it has a 'U' next to the function name). How can a function be exported and yet be undefined (IIRC, a linker option prevents this kind of absurbity). More importantly, what can I do to fix it?
Stick it to THE MAN
By "Fixing it", I mean how can I ensure that my functions are exported AND DEFINED in the shared library?
Stick it to THE MAN
Could it be that the undefined symbol is contained in another shared object? Check out Void's advice.
rpg
A: 

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.

Void