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

san*_*sub 7 c++ unresolved-external visual-c++

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

我将dll中的函数声明为:

string __declspec( dllexport ) ConfigureHAT(T_STRING pathFile);
Run Code Online (Sandbox Code Playgroud)

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

我在dll中调用该函数:

string ret = ConfigureHAT("file.txt");
Run Code Online (Sandbox Code Playgroud)

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

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(类System :: Object ^,类System :: EventArgs ^)"(?buttonConfigure_Click @ mainWindow @ HATdllTester @@ $$ FA $ AAMXP $ 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( class System :: Object ^,class 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'$分配器@ d @ @@ 2 STD @@ V12 @@ Z)

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

谢谢.

编辑

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

blu*_*ish 3

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