简体   繁体   English

C ++链接错误

[英]C++ linkage error

I compile in Visual studio 2008 and get this error. 我在Visual Studio 2008中编译并收到此错误。 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 错误LNK2019:无法解析的外部符号“ void __cdecl betFold(double) ”(?betFold @@ YAXN @ Z)在函数“ void __cdecl flopAction(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)引用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

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. 或者至少链接器找不到该定义,这是因为它在您未引用的库中,或者是因为它在一个不属于构建过程的对象文件(源文件)中。

您的函数void flopAction(std::string arg)使用了betFold(double)函数,该函数在某些标头中被引用和声明,但未实现,因此链接程序可以找到它。

Sound like you forgot to specify the *.lib file that belongs to the *.dll. 听起来好像您忘记了指定属于* .dll的* .lib文件。 You can edit the list under your Project Property Pages -> Configuration properties -> Linker -> Input, remember to do this for the Debug and Release configuration. 您可以在项目属性页->配置属性->链接器->输入下编辑列表,切记对Debug and Release配置进行此操作。

And please try to refrain from phrases like wtf etc :) 并且请尽量避免使用wtf等短语:)

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. 另外,您可以检查签名(函数声明),以便它仅包含其参数列表中的类型,而在定义(.cpp文件)内部,它同时包含类型和参数名称。 For eg, 例如

in the .h file where the declaration sits: 在声明所在的.h文件中:

void myfunc(int, char*);

and in the .cpp file where the definition sits: 在定义所在的.cpp文件中:

void myfunc(int num, char* name)
{
 //
}

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. 我以前在大学里就学过这一点,但是不确定Dev C ++是否支持它,很久以前就离开了,当时是使用Borland。

hope this helps. 希望这可以帮助。 thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM