由于“错误LNK2028:无法解析的令牌...",我无法编译解决方案. [英] I can't compile a solution due to "Error LNK2028: unresolved token..."

查看:76
本文介绍了由于“错误LNK2028:无法解析的令牌...",我无法编译解决方案.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C ++编程的dll和一个用Visual C ++编程的exe.

I have a dll programmed in C++, and a exe programmed in Visual C++.

我在dll中声明了以下功能:

I have the functions in dll declared as:

string __declspec( dllexport ) ConfigureHAT(T_STRING pathFile);

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

And in the exe project I include all the headers files and the dll file.

我在dll中调用该函数:

I call the function in dll:

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

编译可执行项目时,它失败并显示以下错误:

And when the executable project is compiled, it fails with the next errors:

1> HATdllTester.obj:错误LNK2028:无法解析的令牌(0A000317)类std :: basic_string,classstd :: allocator> __cdecl ConfigureHAT(classstd :: basic_string,classstd :: allocator>)(?配置HAT @@ $$ FYA?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)在函数私有:__clrcall中无效"中引用HATdllTester :: mainWindow :: buttonConfigure_Click(类System :: Object^,class System :: EventArgs ^)(?buttonConfigure_Click @ mainWindow @ HATdllTester @@ $$ FA $ AAMXP $ AAVObject @ System @@ P $ AAVEventArgs @ 4 @@ Z)

1>HATdllTester.obj : error LNK2028: unresolved token (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) referenced in function "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> AssemblyInfo.obj:错误LNK2028:无法解析的令牌(0A000316)类std :: basic_string,classstd :: allocator> __cdecl ConfigureHAT(classstd :: basic_string,classstd :: allocator>)(?配置HAT @@ $$ FYA?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)在函数私有:__clrcall中无效"中引用HATdllTester :: mainWindow :: buttonConfigure_Click(类System :: Object^,class System :: EventArgs ^)(?buttonConfigure_Click @ mainWindow @ HATdllTester @@ $$ FA $ AAMXP $ AAVObject @ System @@ P $ AAVEventArgs @ 4 @@ Z)

1>AssemblyInfo.obj : error LNK2028: unresolved token (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) referenced in function "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> AssemblyInfo.obj:错误LNK2019:未解析的外部符号类std :: basic_string,classstd :: allocator> __cdecl ConfigureHAT(classstd :: basic_string,classstd :: allocator>)(?配置HAT @@ $$ FYA?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)在函数私有:__clrcall中无效"中引用HATdllTester :: mainWindow :: buttonConfigure_Click(类System :: Object^,class System :: EventArgs ^)(?buttonConfigure_Click @ mainWindow @ HATdllTester @@ $$ FA $ AAMXP $ AAVObject @ System @@ P $ AAVEventArgs @ 4 @@ Z)

1>AssemblyInfo.obj : error LNK2019: unresolved external symbol "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) referenced in function "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:无法解析的外部符号类std :: basic_string,classstd :: allocator> __cdecl ConfigureHAT(classstd :: basic_string,classstd :: allocator>)(?ConfigureHAT @@ $$ FYA?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)

1>HATdllTester.obj : error LNK2001: unresolved external symbol "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)

有人可以帮助我吗?我读了很多类似的错误消息,但都没有人解决我的问题.

Can anybody help me? I read a lot of similar messages with the same error, but no one solves my problem.

谢谢.

最后,我解决了将dll项目中生成的.lib文件包含到项目属性->链接器->输入->其他依赖项中的问题.

Finally, I solve the problem including the .lib file generated in the dll project into Project Properties -> Linker -> Input -> Additional Dependencies.

推荐答案

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

I'd try changing Visual Studio project configuration. Under General > Common Language Runtime Support set /clr instead of /clr:pure.

这篇关于由于“错误LNK2028:无法解析的令牌...",我无法编译解决方案.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆