I define this in dll compile process.
# if defined(BUILD_DLL)
# define COMMON_API __declspec(dllexport)
# else
# define COMMON_API __declspec(dllimport)
#endif
and:
template <typename T> class COMMON_API Singleton {
public:
static T& GetInstance()
{
static T s_instance;
return s_instance;
};
***
};
and:
class COMMON_API CRegExecThreadPool:public Singleton<CRegExecThreadPool>
{
friend class Singleton<CRegExecThreadPool>;
***
}
then I try use it in exe:
Commonlib::CRegExecThreadPool::GetInstance();
but got the link error,I don't understand why. what can I do?
"__declspec(dllimport) public: static class Commonlib::CRegExecThreadPool & __cdecl Commonlib::Singleton::GetInstance(void)"
error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: static class Commonlib::CRegExecThreadPool & __cdecl Commonlib::Singleton::GetInstance(void)" (_imp?GetInstance@?$Singleton@VCRegExecThreadPool@Commonlib@@@Commonlib@@SAAEAVCRegExecThreadPool@2@XZ)