Test for undefined references in Linux

Posted by Charles on Stack Overflow See other posts from Stack Overflow or by Charles
Published on 2010-05-03T21:11:47Z Indexed on 2010/05/03 21:18 UTC
Read the original article Hit count: 212

Filed under:
|
|

Is there a built in linux utility that I can use to test a newly compiled shared library for external undefined references? Gcc seems to be intelligent enough to check for undefined symbols in my own binary, but if the symbol is a reference to another library gcc does not check at link time. Instead I only get the message when I try to link to my new library from another program.

It seems a little silly to get undefined reference messages in a library when I am compiling a different project so I want to know if I can do a check on all references internal and external when I build the library not when I link to it.

Example error:

make -C  UnitTests debug
make[1]: Entering directory `~/projects/Foo/UnitTests`
g++ [ tons of objects ] -L../libbar/bin -lbar -o UnitTests
libbar.so: undefined reference to `DoSomethingFromAnotherLibrary`
collect2: ld returned 1 exit status
make[1]: *** [~/projects/Foo/UnitTests] Error 1

© Stack Overflow or respective owner

Related posts about c++

Related posts about linux