I have a strange problem. On Windows, with Visual Studio 2010 and also with the Intel Compiler everything is linked as expected. But when I try to compile my code with CLang 3.0 on Linux, it does compile (and if I only use a single CPP file it does also link and run) but does not link.
The message is that there are multiple symbol definitions, referring to template instanciations. For example consider the following two lines in a header file shared across multiple compilation units:
template<class T> void myFunc(T in) { }
template<> void myFunc<int>(int in) { }
Now from the Linux linker I would get something along the lines of:
"file xyz": Multiple definition of "myFunc(int in)", first defined in "some file".
But how would I prevent that? Since it works on Windows I suppose it should work on Linux too somehow?
The same goes for static template data members, which are more or less the same as above just that you declare a variable instead of a function. I would prefer if it worked for static template data members.
If everything else fails I suppose I could still create a "MakeAll.cpp" file which just includes all CPP there are, but that doesn't sound like a desirable solution to me...
Thanks for your help!