• 4700阅读
  • 4回复

请教Qt2编译一个小程序出现的问题 [复制链接]

上一主题 下一主题
离线bluesge
 
只看楼主 倒序阅读 楼主  发表于: 2008-04-08
— 本帖被 XChinux 执行加亮操作(2008-04-12) —
初学QT 遇到一个问题 望大家指点 谢谢!
root@localhost hello]# make
Makefile:119: warning: overriding commands for target `moc_hello.cpp'
Makefile:116: warning: ignoring old commands for target `moc_hello.cpp'
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/root/armsys2410/qt/qt/include -I/root/armsys2410/qt/qtopia/include -o main.o main.cpp
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/root/armsys2410/qt/qt/include -I/root/armsys2410/qt/qtopia/include -o hello.o hello.cpp
/root/armsys2410/qt/qt/bin/moc hello.h -o moc_hello.cpp
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/root/armsys2410/qt/qt/include -I/root/armsys2410/qt/qtopia/include -o moc_hello.o moc_hello.cpp
gcc  -o hello main.o hello.o hello.o moc_hello.o moc_hello.o  -L/root/armsys2410/qt/qt/lib -L/root/armsys2410/qt/qtopia/lib -lm -lqpe -lqtopia -lqte
hello.o(.text+0x0): In function `hello::hello[not-in-charge](QWidget*, char const*, unsigned)':
: multiple definition of `hello::hello[not-in-charge](QWidget*, char const*, unsigned)'
hello.o(.text+0x0): first defined here
hello.o(.text+0x24c): In function `hello::hello[in-charge](QWidget*, char const*, unsigned)':
: multiple definition of `hello::hello[in-charge](QWidget*, char const*, unsigned)'
hello.o(.text+0x24c): first defined here
hello.o(.text+0x498): In function `hello::~hello [not-in-charge]()':
: multiple definition of `hello::~hello [not-in-charge]()'
hello.o(.text+0x498): first defined here
hello.o(.text+0x4bc): In function `hello::~hello [in-charge]()':
: multiple definition of `hello::~hello [in-charge]()'
hello.o(.text+0x4bc): first defined here
hello.o(.text+0x4e0): In function `hello::~hello [in-charge deleting]()':
: multiple definition of `hello::~hello [in-charge deleting]()'
hello.o(.text+0x4e0): first defined here
hello.o(.text+0x50c): In function `hello::say_hello()':
: multiple definition of `hello::say_hello()'
hello.o(.text+0x50c): first defined here
moc_hello.o(.text+0x0): In function `hello::className() const':
: multiple definition of `hello::className() const'
moc_hello.o(.text+0x0): first defined here
moc_hello.o(.data+0x0): multiple definition of `hello::metaObj'
moc_hello.o(.data+0x0): first defined here
moc_hello.o(.text+0xc): In function `hello::initMetaObject()':
: multiple definition of `hello::initMetaObject()'
moc_hello.o(.text+0xc): first defined here
moc_hello.o(.text+0xcc): In function `hello::staticMetaObject()':
: multiple definition of `hello::staticMetaObject()'
moc_hello.o(.text+0xcc): first defined here
moc_hello.o(.text+0x74): In function `hello::tr(char const*)':
: multiple definition of `hello::tr(char const*)'
moc_hello.o(.text+0x74): first defined here
moc_hello.o(.text+0xa0): In function `hello::tr(char const*, char const*)':
: multiple definition of `hello::tr(char const*, char const*)'
moc_hello.o(.text+0xa0): first defined here
collect2: ld returned 1 exit status
make: *** [hello] Error 1
离线guoyun_he

只看该作者 1楼 发表于: 2008-04-09
LD_LIBRARY_PATH 设置正确了吗?
离线bluesge
只看该作者 2楼 发表于: 2008-04-09
export    LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/lib
对吗?
谢谢了!
离线浪漫天使
只看该作者 3楼 发表于: 2008-04-10
我猜测的 你的pro里面有了
INTERFACES = hello.ui

但是你的
HEADERS 里面又有了 hello.h
或者你的
SOURCES 里面有了 hello.cpp

因为hello.ui生成的文件就是hello.h和 hello.cpp 你又把它放到HEADERS 和 SOURCES里面 就导致了多重定义了

其实 INTERFACES = hello.ui里面就包含了对生成的hello.h和 hello.cpp 处理了 就不要往HEADERS 和 SOURCES加hello.ui生成的东西了,也不要另外创建hello.h和 hello.cpp这样的文件,因为会被生成的覆盖了.......
离线bluesge
只看该作者 4楼 发表于: 2008-04-12
谢谢了!!!!!!!!!!!!!!!!!!!!!!!!!!!
谢谢了!!!!!!!!!!!!!!!!!!!!!!!!!!!
快速回复
限100 字节
 
上一个 下一个