在网上找了下multiple definition of 报错的问题,但发现和我的都不太一样。
错误信息如下:
debug/moc_test.o:D:\work\qtproject\test-build-simulator/debug/moc_test.cpp:82: multiple definition of `A::fun()'
debug/test.o:D:\work\qtproject\test-build-simulator/../test/test.cpp:4: first defined here
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\test.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "D:/NokiaQtSDK/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project test (target: Qt Simulator)
When executing build step 'Make
工程就是一个简单向导工程,然后只是自己添加了一个类,定义如下
//test.h
#ifndefTEST_H
#defineTEST_H
#include<QObject>
classA:publicQObject
{
Q_OBJECT
signals: //出问题的地方
voidfun();
};
#endif//TEST_H
//test.cpp
#include"test.h"
voidA::fun(){}
//test.pro
QT += core gui
TARGET = test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
test.cpp
HEADERS += mainwindow.h \
test.h
一加上singals就出错,
大家有遇到过这种问题吗。
谢谢。