我做了 2 个项目:一个是提供者,在里面我添加了一个类 DH:
using namespace std;
#ifdef PROVIDER_EXPORTS
#define DH_API __declspec(dllexport)
#else
#define DH_API __declspec(dllimport)
#endif
#include <iostream>
namespace Provider
{
class DH
{
public:
static DH_API std::string GetKey();
};
}
和小鬼:
#include "DH.h"
using namespace std;
namespace Provider
{
std::string DH::GetKey()
{
return "KEY";
}
}
当我转储dll时,我得到:
?GetKey@DH@Provider@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ = @ILT+10(?GetKey@DH@Provider@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
在一个新项目上 - 我包含 dh.h 的测试仪我已将 Provider 项目的调试文件夹添加到链接目录
我只是打电话DH::GetKey
但是当我编译时我得到:
LNK2019: unresolved external symbol "__declspec(dllimport) public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Provider::DH::GetKey(void)" (__imp_?GetKey@DH@Provider@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)
怎么了?