pserver.o: In function `tempSpace::nextPrime(int)':
pserver.cpp:(.text+0x0): multiple definition of `tempSpace::nextPrime(int)'
sim.o:sim.cpp:(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [passServer] Error 1
I am thinking that it has something to do with the namespace I am using, or possibly what and where I am including my header files, so I am going to post the code fragments of those (sorry if this is hard to follow):
So, the error message suggests that I am defining nextPrime(int) multiple times, BUT the declaration and definition are in hashmap.hpp ONLY. It does not exist in any other files. So why does the compiler think that I am defining it multiple times?
The definition of nextPrime will appear everywhere you include hashmap.hpp, as so everywhere you include hashmap.h ( since it includes hashmap.hpp.
You should either decalre it as inline or move its definition in a source file ( the latter is better )
Well, sim.cpp includes pserver.h which includes hasmap.h which includes hashmap.hpp which defines the function. pserver.cpp does the same, so you get the function defined in both sim.cpp and pserver.cpp.
The thing to do here would be not to define functions (unless they are templates (or inline if I recall correctly) ) in headers.