关于“error LNK2005:…… already defined in”的解决办法

语音Dlg.obj : error LNK2005: "public: void __thiscall CMFCC::InitMelFilterBanks(float,float,int,int)" ([email=?InitMelFilterBanks@CMFCC@@QAEXMMHH@Z]?InitMelFilterBanks@CMFCC@@QAEXMMHH@Z[/email]) already defined in 语音.obj
语音Dlg.obj : error LNK2005: "public: void __thiscall CMFCC::PRFFT_NEW(float *,float *,int,int,int)" ([email=?PRFFT_NEW@CMFCC@@QAEXPAM0HHH@Z]?PRFFT_NEW@CMFCC@@QAEXPAM0HHH@Z[/email]) already defined in 语音.obj
语音Dlg.obj : error LNK2005: "public: void __thiscall CMFCC::MelFilterBank(float *,int,float *,int)" ([email=?MelFilterBank@CMFCC@@QAEXPAMH0H@Z]?MelFilterBank@CMFCC@@QAEXPAMH0H@Z[/email]) already defined in 语音.obj
语音Dlg.obj : error LNK2005: "public: float __thiscall CMFCC::LogE(float)" ([email=?LogE@CMFCC@@QAEMM@Z]?LogE@CMFCC@@QAEMM@Z[/email]) already defined in 语音.obj
语音Dlg.obj : error LNK2005: "public: void __thiscall CMFCC::FilterBankBasic(float *,int,float *,int,int,int,int)" ([email=?FilterBankBasic@CMFCC@@QAEXPAMH0HHHH@Z]?FilterBankBasic@CMFCC@@QAEXPAMH0HHHH@Z[/email]) already defined in 语音.obj
语音Dlg.obj : error LNK2005: "public: void __thiscall CMFCC::DCT(float *,float *,int,int,float *)" ([email=?DCT@CMFCC@@QAEXPAM0HH0@Z]?DCT@CMFCC@@QAEXPAM0HH0@Z[/email]) already defined in 语音.obj
语音Dlg.obj : error LNK2005: "public: void __thiscall CMFCC::MelCepstrumBasic(float *,int,float *,int,int,int)" ([email=?MelCepstrumBasic@CMFCC@@QAEXPAMH0HHH@Z]?MelCepstrumBasic@CMFCC@@QAEXPAMH0HHH@Z[/email]) already defined in 语音.obj
语音Dlg.obj : error LNK2005: "public: void __thiscall CMFCC::MFCC(float *,int,float *,int)" ([email=?MFCC@CMFCC@@QAEXPAMH0H@Z]?MFCC@CMFCC@@QAEXPAMH0H@Z[/email]) already defined in 语音.obj
Debug/语音.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
Creating browse info file...
语音.exe - 1 error(s), 0 warning(s)


编写MFC程序时,自定义类(未用MFC类生成向导定义的类,类定义与成员函数都放在.h头文件里),若其成员函数放在类定义外,必须成员函数定义处必须加上“inline”,即将成员函数定义为内置函数!否则,链接时就会出现“error LNK2005:…… already defined in”错误!
此类错误解决办法:
1、将成员函数定义移入类定义内;
2、在成员函数定义加上“inline”,即将成员函数定义为内置函数
3、改用MFC类生成向导定义类

你可能感兴趣的:(C++笔记)