2011-11-17 134 views
12

我知道你已经看到了21728517人,要求与这一个帮助,但搜索和阅读这之后我真的想不通这一个。我知道这个错误,但之前我已经看到过,但这一次,我似乎无法绕过它。LNK2005(已定义)

我也试过这个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)" ([email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 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)" ([email protected]@[email protected]) 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)" ([email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@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。我究竟做错了什么?

在此先感谢。

+5

#包含多个.cpp文件中的.h文件会触发此链接器错误。应该只有*一个*定义。你可以把*内联*放在它的前面。 –

回答

21

定义功能misc.cpp,而不是在misc.h

的问题可能是由于#include荷兰国际集团misc.h多个CPP文件。头部防护装置防止在多次包括在相同的翻译单元的报头,但是每个CPP文件是(通常)单独的翻译单元。所以这些功能最终定义了两次 - 每个翻译单元都有一次。

+0

那是我的愚蠢。我以前有一个单独的.cpp。我必须改变它。谢谢 :) – takecare

相关问题