首页 文章

由于“错误LNK2028:未解析的令牌......”,我无法编译解决方案

提问于
浏览
6

我有一个用C编程的dll,以及用Visual C编写的exe .

我将dll中的函数声明为:

string __declspec( dllexport ) ConfigureHAT(T_STRING pathFile);

在exe项目中,我包含了所有头文件和dll文件 .

我在dll中调用该函数:

string ret = ConfigureHAT("file.txt");

当编译可执行项目时,它会因下一个错误而失败:

1> HATdllTester.obj:错误LNK2028:未解析的令牌(0A000317)“class std :: basic_string,class std :: allocator> __cdecl ConfigureHAT(class std :: basic_string,class std :: allocator>)”(?ConfigureHAT @@ $$ FYA?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)在函数“private:void __clrcall HATdllTester :: mainWindow: :buttonConfigure_Click(类System :: Object ^,类System :: EventArgs ^)“(?buttonConfigure_Click @mainWindow @ HATdllTester @@ $$ FA $ AAMXP $ AAVObject @ System @@ P $ AAVEventArgs @ 4 @@ Z)1> AssemblyInfo .obj:错误LNK2028:未解析的令牌(0A000316)“class std :: basic_string,class std :: allocator> __cdecl ConfigureHAT(class std :: basic_string,class std :: allocator>)”(?ConfigureHAT @@ $$ FYA? AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)在函数“private:void __clrcall HATdllTester :: mainWindow :: buttonConfigure_Click(class)”中引用System :: Object ^,类System :: EventArgs ^)“(?buttonConfigure_Click @ mainWindow @ HATdllTester @@ $$ FA $ A AMXP $ AAVObject @ System @@ P $ AAVEventArgs @ 4 @@ Z)1> AssemblyInfo.obj:错误LNK2019:未解析的外部符号“class std :: basic_string,class std :: allocator> __cdecl ConfigureHAT(class std :: basic_string, class std :: allocator>)“(?ConfigureHAT @@ $$ FYA?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)在函数“private:void __clrcall HATdllTester :: mainWindow :: buttonConfigure_Click(类System :: Object ^,类System :: EventArgs ^)”中引用“(?buttonConfigure_Click @ mainWindow @ HATdllTester @@ $$ FA $ AAMXP $ AAVObject @ System @ @ P $ AAVEventArgs @ 4 @@ Z)1> HATdllTester.obj:错误LNK2001:未解析的外部符号“class std :: basic_string,class std :: allocator> __cdecl ConfigureHAT(class std :: basic_string,class std :: allocator> )“(?ConfigureHAT @@ $$ FYA?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)

有谁能够帮我?我读了很多类似的错误,但是没有人解决我的问题 .

谢谢 .

编辑

最后,我解决了问题,包括在dll项目中生成的.lib文件到Project Properties - > Linker - > Input - > Additional Dependencies .

1 回答

  • 3

    我尝试更改Visual Studio项目配置 . 在常规>公共语言运行时支持下设置 /clr 而不是 /clr:pure .

相关问题