Information
We are currently investigating an issue with the editor of some pages. Please save your work and avoid to create new pages until this banner is gone.
Why is [the linker | the library loader at runtime] complaining about an undefined symbol which I declared as static member of one of my classes?
You forgot to instanciate the static member.
Whenever you declare a static member in one of your classes, then this declaration servers as a "place holder" telling the compiler/linker that this object will be defined elsewhere.
Normally you will declare the static member in the include file and define it, i.e. allocate memory for it, in a cpp
file.
class Foo { private: static boolean active; };
#include <foo.h> boolean Foo::active(false);
There is a way to tell which symbols are undefined:
nm --demangle=auto -u [YOUR_LIBRARY | YOUR_OBJECT_FILE]to detect all undefined symbols.
-- ThomasJuerges - 30 Nov 2006