C++链接错误
我在 Visual Studio 2008 中编译并收到此错误。我研究过链接错误,但仍然不确定它是什么。这是扑克游戏的完成代码,所以我不想发布代码。有人可以帮我翻译这个错误消息吗?
错误 LNK2019:函数“
void __cdecl flopAction(class std::basic_string
”中引用了无法解析的外部符号“
" (void __cdecl betFold(double)
”(?betFold@@YAXN@Z) char,struct std::char_traits,class std::allocator ; >) ?flopAction@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
) OH-DLL.obj
I compile in Visual studio 2008 and get this error. I have researched linkage error but am still uncertain to what it is. This is the finished code to a poker game so I would rather not post the code. Can someone translate this error message for me?
error LNK2019: unresolved external symbol "
void __cdecl betFold(double)
" (?betFold@@YAXN@Z) referenced in function "void __cdecl flopAction(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)
" (?flopAction@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
) OH-DLL.obj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的函数
void flopAction(std::string arg)
使用了一个函数betFold(double)
,该函数在某些标头中被引用和声明,但未实现,因此链接器能够找到它。Your function
void flopAction(std::string arg)
uses a functionbetFold(double)
that gets referenced and declared in some header, but is not implemented so that the linker is able to find it.这意味着您已声明此方法但未定义它。或者至少链接器找不到定义,要么因为它位于您未引用的库中,要么因为它位于不属于构建过程的目标文件(源文件)中。
It means that you have declared this method but not defined it. Or at least the linker cannot find the definition, either because it’s in a library that you didn’t reference or else because it’s in an object file (source file) that is not part of your build process.
听起来您忘记指定属于 *.dll 的 *.lib 文件。您可以在项目属性页 -> 下编辑列表配置属性->链接器->输入,记住对 Debug 和 Release 配置都要这样做。
请尽量避免使用“wtf”等短语:)
Sound like you forgot to specify the *.lib file that belongs to the *.dll. You can edit the list under your Project Property Pages -> Configuration properties -> Linker -> Input, remember to do this for the Debug and Release configuration.
And please try to refrain from phrases like wtf etc :)
另外,您可以检查您的签名(函数声明),以便它仅包含其参数列表中的类型,而在定义(.cpp 文件)内,它包含类型和参数名称。例如,
在声明所在的 .h 文件中:
和定义所在的 .cpp 文件中:
我以前在大学里学过这个,但不确定 Dev C++ 是否支持它,把这个东西留了很长时间以前,当时只是使用Borland。
希望这有帮助。
谢谢。
Also, you could check your signature(function declaration), so that it contains only the type in it's parameter lists, while inside the definition(.cpp file), it contains both the type and parameter names. For eg,
in the .h file where the declaration sits:
and in the .cpp file where the definition sits:
I learnt this before in my college, but don't sure if Dev C++ supports it, left this things for a long time ago, just using Borland at that time.
hope this helps.
thanks.