• 9290阅读
  • 3回复

请教编译时multiple definition 错误的问题 [复制链接]

上一主题 下一主题
离线vance
 
只看楼主 倒序阅读 楼主  发表于: 2010-09-03
— 本帖被 XChinux 执行加亮操作(2010-09-03) —
在网上找了下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就出错
大家有遇到过这种问题吗。
谢谢。
离线dbzhang800

只看该作者 1楼 发表于: 2010-09-03
你这么弄当然要出错了, signals 的函数会由 moc 自动生成,你在 cpp 内又自己定义了一个!
离线vance
只看该作者 2楼 发表于: 2010-09-16
恩恩,是的,谢谢
离线foxyz

只看该作者 3楼 发表于: 2010-09-21
signals: //出问题的地方
    voidfun();

你自己都发现问题了!!
快速回复
限100 字节
 
上一个 下一个