c – LNK2005(已定义)

我知道你已经看到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,class std::allocator<class std::basic_string<char,class std::allocator<char> > > > __cdecl explode(class std::basic_string<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的死亡.我究竟做错了什么?

提前致谢.

解决方法

定义misc.cpp中的函数,而不是在misc.h中.

问题可能是由于#include在多个CPP文件中的misc.h.头部保护装置防止在相同的翻译单元中多次包括标题,但是每个CPP文件(通常是)单独的翻译单元.所以这些功能最终被定义了两次 – 在每个翻译单元中一次.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...