error LNK2001: unresolved external symbol "__declspec(dllimport) const CNoteMgr::`vftable'"

编译动态链接库报错:

error LNK2001: unresolved external symbol "__declspec(dllimport) const CNoteMgr::`vftable'" (__imp_??_7CNoteMgr@@6B@)

 

对于动态链接库应该用的是__declspec(dllexport),而现在却是__declspec(dllimport)。

我是这样调用的 class NOTE_API CNoteMgr

 

所以看下NOTE_API宏定义:

#ifdef   NOTE_API_EXPORTS  
  #define   NOTE_API   __declspec(dllexport)  
  #else  
  #define   NOTE_API   __declspec(dllimport)  
  #endif  

 

原来还要定义NOTE_API_EXPORTS宏,但是我搜索了示例程序的代码,根本没有发现NOTE_API_EXPORTS的定义,后来才想起来在VC工程的project->setting->C/C++->Preprocessor definitions中添加NOTE_API_EXPORTS即可。

 

你可能感兴趣的:(api,Class)