我知道你已经看到21728517人在这个问题上寻求帮助,但在搜索和阅读了这个问题后,我真的搞不懂这个问题。我知道这个错误,我以前见过它,但是这一次,我似乎无法绕过它。
我也尝试过这个checklist。
因此,错误如下:
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所以,问题是,这些都是在"misc.h“中定义的函数,使用适当的#ifndef #define #endif。它们在其他地方没有定义,但我仍然得到了死亡的LNK2005。我做错了什么?
提前谢谢。
发布于 2011-11-18 00:59:28
在misc.cpp中而不是在misc.h中定义函数。
该问题可能是由于在多个CPP文件中#include misc.h造成的。报头保护防止在同一转换单元中多次包括报头,但是每个CPP文件(通常)是单独的转换单元。因此,这些函数最终定义了两次--在每个翻译单元中定义一次。
https://stackoverflow.com/questions/8171102
复制相似问题