> one or more multiply defined symbols found
Two common mistakes
1. having
#include "somefile.cpp" somewhere in the code, as a way to avoid having to add source files to your project / makefile.
2. having definitions (hence the error message - multiple definitions) in header files.
A definition would be something like
1 2 3 4
|
void foo ( ) {
cout << "this is foo";
}
int bar = 42;
| |
There are some exceptions:
- function definitions within the declaration of a class are OK in header files.
- function definitions which are part of a template are OK in header files.
- function definitions which have the
inline specifier are OK in header files.
- function definitions which have the
static specifier are OK in header files.