简体   繁体   English

LNK2005(已定义)

[英]LNK2005 (already defined)

I know you've seen 21728517 people asking for help with this one but after searching and reading about this I really can't figure this one out. 我知道您已经看到21728517人对此寻求帮助,但是在搜索并阅读了有关此信息之后,我真的无法弄明白这一点。 I know this error, I've seen it before, however, this time, I can't seem to get around it. 我知道这个错误,我以前见过,但是这次,我似乎无法解决它。

I've also tried this checklist . 我也尝试过此清单

So, the errors: 因此,错误:

Error   25  error LNK2005: "void __cdecl checkStatus(unsigned int &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,bool)" (?checkStatus@@YAXAAIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z) already defined in DollarRecognizer.obj C:\Users\Rui Teixeira\Desktop\Current\Tese\SVN\TIFEE_Empty\TIFEE_Empty\main.obj TIFEE_Empty

Error   26  error LNK2005: "void __cdecl depth2rgb(unsigned short const *,unsigned short *,char *,int,int)" (?depth2rgb@@YAXPBGPAGPADHH@Z) already defined in DollarRecognizer.obj  C:\Users\Rui Teixeira\Desktop\Current\Tese\SVN\TIFEE_Empty\TIFEE_Empty\main.obj TIFEE_Empty

Error   27  error LNK2005: "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl explode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,char)" (?explode@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@D@Z) already defined in DollarRecognizer.obj    C:\Users\Rui Teixeira\Desktop\Current\Tese\SVN\TIFEE_Empty\TIFEE_Empty\main.obj TIFEE_Empty

So, the thing is, these are functions defined in "misc.h" with the proper #ifndef #define #endif. 所以,事实是,这些是在“ misc.h”中定义的函数,带有正确的#ifndef #define #endif。 They are not defined elsewhere but I still get the LNK2005 of death. 他们没有在其他地方定义,但我仍然得到死亡的LNK2005。 What am I doing wrong? 我究竟做错了什么?

Thanks in advance. 提前致谢。

Define the functions in misc.cpp , rather than in misc.h . misc.cpp中而不是misc.h定义函数。

The problem is probably due to #include ing misc.h in multiple CPP files. 问题可能是由于#include在多个CPP文件中misc.h引起的。 the header guards prevent a header from being included multiple times in the same translation unit , but each CPP file is (typically) a separate translation unit. 标头防护可防止在同一翻译单元中多次包含标头,但每个CPP文件(通常)是一个单独的翻译单元。 So those functions end up getting defined twice -- once in each translation unit. 因此,这些功能最终要定义两次-每个翻译单元一次。

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

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