Are all #ifndef's properly made? If you're using Visual Studio you can try putting a #pragma once at first line in all headers. If this helps something is wrong with the #ifndef's
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
Neither #pragma once nor include guards (#ifndefs) can protect you against linker errors! They're only useful during the compile, not the link.
In general, non-template functions and variables cannot be defined in a header file or else you're likely to end up with this error. You should put them in a cpp file, and if necessary in the case of global variables, extern-declare them in the header.
There are a few other options as well. Declaring functions inline usually allows them to be placed in the header. Declaring variables static works the same way (but may be misleading, because each translation unit will have a different version of the "global" variable!). Singleton classes, classes with static members, etc are also options.
Bookmarks