Difference between revisions of "Development/Tutorials/Debugging Linker Errors"

Jump to: navigation, search
(Tell people how to debug undefined symbols)
Line 1: Line 1:
{{Template:I18n/Language Navigation Bar|Development/Tutorials/Debugging Linker Errors}}

Latest revision as of 16:27, 19 July 2012

Debugging Linker Errors
Tutorial Series   Getting Started
Previous   None
What's Next   n/a
Further Reading   n/a

[edit] Abstract

This tutorial gives precise steps for debugging issues related to linking of applications and libraries.

[edit] Undefined symbol

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.

This page was last modified on 19 July 2012, at 16:27. This page has been accessed 7,106 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal