I have a class like this
class A_DLL A
{
...
template <class T> someFunction(const T &v);
}
in library a.dll. A_DLL is __declspec(dllexport) when building a.dll and __declspec(dllimport) when using a.dll.
The problem is when I try to use ‘someFunction’ in some executable module linked against a.dll it works. However when I use it in some other library (b.dll) it gives me an error message about unresolved externals (someFunction and other templates). Obviously I should not use __declspec on templates but how then to make a class with __declspec?
You can use the declaration like:
This statement will generate the template class instantiation and export it in the DLL you are building (or import it depending on how A_DLL is set from preprocessor).
You could also follow this link for a more detailed description.