In visual c++, I created a static library with two files, myLib.h and myLib.cpp. I also have a console application project with the file testSequence.cpp that references this library.
Within myLib.h I have defined a class template<class prec> class sequence which has the function declaration prec *getPrimes(int numToGet) this function is then defined in myLib.cpp. However, when I build testSequence, there is a linking error, and it says error LNK2019: unresolved external symbol "public: int * __thiscall mathLib::sequence<int>::getPrimes(int)" (?getPrimes@?$sequence@H@mathLib@@QAEPAHH@Z) referenced in function "char * __cdecl codeString(char *,char *,bool)" (?codeString@@YAPADPAD0_N@Z)
So, yeah, help would be nice.
In visual c++, I created a static library with two files, myLib.h and myLib.cpp.
Share
Read this for an explanation of the error.
Basically, what you’re trying to do cannot be done. The compiler must be able to see the implementation of the class template when it tries to instantiate it for a given template type parameter. You need to move the implementations for all the member functions to the header file.