Development/Tutorials/Debugging Linker Errors
| Tutorial Series
|| Getting Started
| What's Next
| Further Reading
This tutorial gives precise steps for debugging issues related to linking of applications and libraries.
When the linker says undefined reference to 'Foo', and you don't understand why, follow the following steps:
- Check that the library that is supposed to provide this symbol is actually in the link line. To see the full link line with cmake, use make VERBOSE=1. If -lkdecore is the link line, then we're at least asking the linker to link to libkdecore.
- Check that the right version of the library is linked in, rather than one from the wrong place. To see which library is actually used by ld, copy/paste the full link line from make VERBOSE=1, and add to it: -Q -v -Wl,-t. Somewhere in the verbose output you'll see the full path to each library being used.
- Check that the library actually provides the symbol. nm -D -C /path/to/lib.so | grep Foo will tell you. If the symbol shows up with a 'T' or a 'W' in the second column, then it is indeed provided by the library. If it shows up with a 'U' then it is undefined in this library, and is supposed to be provided by another.
Content is available under Creative Commons License SA 4.0
unless otherwise noted.