Kdevelop4错误 main.cpp(text+0x13):undefined reference to .....
Qyee 2010-05-17 11:16:22 下面是三个文件
1、main.cpp
#include <iostream>
using namespace std;
#include "ServerSettings.h"
#define MAX_TEAM_LENGTH 32
int main(int argc, char **argv) {
ServerSettings ss;
PlayerSettings cs;
char strTeamName[MAX_TEAM_LENGTH]="Qt"; //the teamname
int iPort = ss.getPort();
return 0;
}
2、ServerSettings.cpp
class ServerSettings
{
public:
ServerSettings();
int getPort();
};
3、ServerSettings.cpp
#include "ServerSettings.h"
#ifndef _SERVERSETTINGS_
#define _SERVERSETTINGS_
ServerSettings::ServerSettings()
{}
int ServerSettings::getPort()
{
return 0;
}
#endif
在“project”-->"Build all Projets ".出现下面错误 ,请高手帮忙。。。。。。。
/home/zhuhaiqing/Qt/Qt/src/build/>make
[100]Build CXX object CMakeFiles/qt.dir/main.cpp.o
link CXX executable qt
CMakeFiles/qt.dir/main.cpp.o:In function 'main':
main.cpp:(text+0x13):undefined reference to 'ServerSettings::ServerSetting()'
main.cpp:(text+0x13):undefined reference to 'ServerSettings::getPort()'
collect2:ld returened 1 exit status
make[2]:*** [qt]错误 1
make[1]:*** [CMakeFiles/qt.dir/all]错误 2
make:***[all] 错误 2
***Failed***
希望给出解答方法,我知道错误的原因是函数的实现没有被找到。不知道怎么解决。。。。。。
40分不少了吧。麻烦大家了