当前位置: 技术问答>linux和unix
新手求助!Qt嵌入式图形开发方面的
来源: 互联网 发布时间:2016-06-27
本文导语: 我用designer建立一个test.ui文件,前面都很顺利,就是到make这一步执行不过去,老是提示下面错误,我都看不出这是什么错误,请大侠看看是什么错误 [root@localhost Lily]# cd /opt/test [root@localhost test]# ls main.cpp Make...
我用designer建立一个test.ui文件,前面都很顺利,就是到make这一步执行不过去,老是提示下面错误,我都看不出这是什么错误,请大侠看看是什么错误
[root@localhost Lily]# cd /opt/test
[root@localhost test]# ls
main.cpp Makefile moc_test.o test.cpp test.o test.ui
main.o moc_test.cpp test.app test.h test.pro
[root@localhost test]# tmake -o Makefile test.pro
[root@localhost test]# make
Makefile:120: warning: overriding commands for target `moc_test.cpp'
Makefile:117: warning: ignoring old commands for target `moc_test.cpp'
g++ -o test test.o main.o test.o moc_test.o moc_test.o -L/opt/qtx86-2.3.4/lib -lm -lqte
test.o(.text+0x0): In function `testwidget::testwidget[not-in-charge](QWidget*, char const*, unsigned)':
: multiple definition of `testwidget::testwidget[not-in-charge](QWidget*, char const*, unsigned)'
test.o(.text+0x0): first defined here
test.o(.text+0x10c): In function `testwidget::testwidget[in-charge](QWidget*, char const*, unsigned)':
: multiple definition of `testwidget::testwidget[in-charge](QWidget*, char const*, unsigned)'
test.o(.text+0x10c): first defined here
test.o(.text+0x218): In function `testwidget::~testwidget [not-in-charge]()':
: multiple definition of `testwidget::~testwidget [not-in-charge]()'
test.o(.text+0x218): first defined here
test.o(.text+0x23c): In function `testwidget::~testwidget [in-charge]()':
: multiple definition of `testwidget::~testwidget [in-charge]()'
test.o(.text+0x23c): first defined here
test.o(.text+0x260): In function `testwidget::~testwidget [in-charge deleting]()':
: multiple definition of `testwidget::~testwidget [in-charge deleting]()'
test.o(.text+0x260): first defined here
moc_test.o(.text+0xcc): In function `testwidget::staticMetaObject()':
: multiple definition of `testwidget::staticMetaObject()'
moc_test.o(.text+0xcc): first defined here
moc_test.o(.text+0x0): In function `testwidget::className() const':
: multiple definition of `testwidget::className() const'
moc_test.o(.text+0x0): first defined here
moc_test.o(.data+0x0): multiple definition of `testwidget::metaObj'
moc_test.o(.data+0x0): first defined here
moc_test.o(.text+0xc): In function `testwidget::initMetaObject()':
: multiple definition of `testwidget::initMetaObject()'
moc_test.o(.text+0xc): first defined here
moc_test.o(.text+0x74): In function `testwidget::tr(char const*)':
: multiple definition of `testwidget::tr(char const*)'
moc_test.o(.text+0x74): first defined here
moc_test.o(.text+0xa0): In function `testwidget::tr(char const*, char const*)':
: multiple definition of `testwidget::tr(char const*, char const*)'
moc_test.o(.text+0xa0): first defined here
collect2: ld returned 1 exit status
make: *** [test] Error 1
[root@localhost Lily]# cd /opt/test
[root@localhost test]# ls
main.cpp Makefile moc_test.o test.cpp test.o test.ui
main.o moc_test.cpp test.app test.h test.pro
[root@localhost test]# tmake -o Makefile test.pro
[root@localhost test]# make
Makefile:120: warning: overriding commands for target `moc_test.cpp'
Makefile:117: warning: ignoring old commands for target `moc_test.cpp'
g++ -o test test.o main.o test.o moc_test.o moc_test.o -L/opt/qtx86-2.3.4/lib -lm -lqte
test.o(.text+0x0): In function `testwidget::testwidget[not-in-charge](QWidget*, char const*, unsigned)':
: multiple definition of `testwidget::testwidget[not-in-charge](QWidget*, char const*, unsigned)'
test.o(.text+0x0): first defined here
test.o(.text+0x10c): In function `testwidget::testwidget[in-charge](QWidget*, char const*, unsigned)':
: multiple definition of `testwidget::testwidget[in-charge](QWidget*, char const*, unsigned)'
test.o(.text+0x10c): first defined here
test.o(.text+0x218): In function `testwidget::~testwidget [not-in-charge]()':
: multiple definition of `testwidget::~testwidget [not-in-charge]()'
test.o(.text+0x218): first defined here
test.o(.text+0x23c): In function `testwidget::~testwidget [in-charge]()':
: multiple definition of `testwidget::~testwidget [in-charge]()'
test.o(.text+0x23c): first defined here
test.o(.text+0x260): In function `testwidget::~testwidget [in-charge deleting]()':
: multiple definition of `testwidget::~testwidget [in-charge deleting]()'
test.o(.text+0x260): first defined here
moc_test.o(.text+0xcc): In function `testwidget::staticMetaObject()':
: multiple definition of `testwidget::staticMetaObject()'
moc_test.o(.text+0xcc): first defined here
moc_test.o(.text+0x0): In function `testwidget::className() const':
: multiple definition of `testwidget::className() const'
moc_test.o(.text+0x0): first defined here
moc_test.o(.data+0x0): multiple definition of `testwidget::metaObj'
moc_test.o(.data+0x0): first defined here
moc_test.o(.text+0xc): In function `testwidget::initMetaObject()':
: multiple definition of `testwidget::initMetaObject()'
moc_test.o(.text+0xc): first defined here
moc_test.o(.text+0x74): In function `testwidget::tr(char const*)':
: multiple definition of `testwidget::tr(char const*)'
moc_test.o(.text+0x74): first defined here
moc_test.o(.text+0xa0): In function `testwidget::tr(char const*, char const*)':
: multiple definition of `testwidget::tr(char const*, char const*)'
moc_test.o(.text+0xa0): first defined here
collect2: ld returned 1 exit status
make: *** [test] Error 1
|
用uic
|
这个问题我也遇到过,问题出在你的Makefile上。仔细检查你的makefile,关于文件依赖
关系的部分一定有语句重复,比如出现同样两句声明要链接同一个.o文件,导致编译器链接
不知道到底链接哪一个.o文件,于是报错重复定义
关系的部分一定有语句重复,比如出现同样两句声明要链接同一个.o文件,导致编译器链接
不知道到底链接哪一个.o文件,于是报错重复定义