I have this template smart pointer class in a dll.
sp.h
---------
#ifdef VLIB_EXPORTS
#define VLIB_API __declspec(dllexport)
#else
#define VLIB_API __declspec(dllimport)
#endif
template < typename T > class VLIB_API SP
{
protected:
        T*    m_pData;
    long*       m_pRefCounter;
public:
    SP(void);
    {
        m_pData = NULL;
        m_pRefCounter = NULL;
    }
    ...
    ...
};
ImagePtr.h
---------------
class VLIB_API CVImagePtr
{
    ....
}
MainLib.h
-------------
#include sp.h
#include ImagePtr.h
typedef SP<CVBlob> CVBlobPtr;
class VLIB_API CVLib
{
public:
    virtual CVBlobPtr CreateBlob() = 0;
    virtual CVImagePtr CreateImg() = 0;
};
When I try to use this class in another project (CVMLib), the compiler will complain this: error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall SP::~SP(void)"
but no problem for CVImagePtr.
class VMLIB_API CVMLib : public CVLib
{
public:
    virtual  CVBlobPtr CreateBlob();
    virtual CVImagePtr CreateImg();
};
It seems there's a problem when the class is a template. If so, how do I export a template class?
Can somebody help me resolve this? Thank you!
 
     
    