2011-11-17 81 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