• 5235阅读
  • 5回复

【提问】qt程序编译问题 [复制链接]

上一主题 下一主题
离线linuzer
 

只看楼主 倒序阅读 楼主  发表于: 2006-03-07
小弟由于项目设计的需要 新近才开始学qt
我用的是magic linux
我编译的第一个hello,world程序就出现了问题:
好像是没有连接qt的lib
以下是出错提示
[root@MagicLinux qt]# make
g++ -o qt hello.o   -L/usr/X11R6/lib -lXext -lX11 -lm
hello.o: In function `main':
/root/src/qt/hello.cpp:6: undefined reference to `QApplication::QApplication(int&, char**)'
/root/src/qt/hello.cpp:8: undefined reference to `QString::QString(char const*)'
/root/src/qt/hello.cpp:8: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*, char const*)'
hello.o: In function `main':
/usr/lib/qt-3.3/include/qstring.h:847: undefined reference to `QString::shared_null'
/usr/lib/qt-3.3/include/qstring.h:848: undefined reference to `QStringData::deleteSelf()'
hello.o: In function `main':
/root/src/qt/hello.cpp:9: undefined reference to `QPushButton::resize(int, int)'
/root/src/qt/hello.cpp:10: undefined reference to `QApplication::setMainWidget(QWidget*)'
/root/src/qt/hello.cpp:11: undefined reference to `QWidget::show()'
/root/src/qt/hello.cpp:12: undefined reference to `QApplication::exec()'
/root/src/qt/hello.cpp:12: undefined reference to `QPushButton::~QPushButton()'
/root/src/qt/hello.cpp:12: undefined reference to `QApplication::~QApplication()'
hello.o: In function `main':
/usr/lib/qt-3.3/include/qstring.h:847: undefined reference to `QString::shared_null'
/usr/lib/qt-3.3/include/qstring.h:848: undefined reference to `QStringData::deleteSelf()'
hello.o: In function `main':
/root/src/qt/hello.cpp:12: undefined reference to `QApplication::~QApplication()'
/root/src/qt/hello.cpp:12: undefined reference to `QPushButton::~QPushButton()'
hello.o:(.gnu.linkonce.r._ZTV6QGList+0xc): undefined reference to `QGList::clear()'
hello.o:(.gnu.linkonce.r._ZTV6QGList+0x10): undefined reference to `QGList::~QGList()'
hello.o:(.gnu.linkonce.r._ZTV6QGList+0x14): undefined reference to `QGList::~QGList()'
hello.o:(.gnu.linkonce.r._ZTV6QGList+0x18): undefined reference to `QPtrCollection::newItem(void*)'
hello.o:(.gnu.linkonce.r._ZTV6QGList+0x20): undefined reference to `QGList::compareItems(void*, void*)'
hello.o:(.gnu.linkonce.r._ZTV6QGList+0x24): undefined reference to `QGList::read(QDataStream&, void*&)'
hello.o:(.gnu.linkonce.r._ZTV6QGList+0x28): undefined reference to `QGList::write(QDataStream&, void*) const'
hello.o:(.gnu.linkonce.r._ZTI6QGList+0x8): undefined reference to `typeinfo for QPtrCollection'
collect2: ld returned 1 exit status
make: *** [qt] 错误 1
[ 此贴被XChinux在2006-03-07 12:41重新编辑 ]
离线linuzer

只看该作者 1楼 发表于: 2006-03-07
问题解决
是不 是所有的qt程序都要有一个main.c的主程序?
离线ziding

只看该作者 2楼 发表于: 2006-03-08
不需要,但是都需要一个main函数,或者指定程序的入口点。
刚开始学习QT,希望各位高手不吝赐教,谢谢~
离线marship
只看该作者 3楼 发表于: 2006-03-08
请参照样子程序做,尽可能用qmake生成makefile,因为qt程序编译时可能要利用一些工具比如moc等,并且编译时要加上很多头文件和库文件目录,连接时也要加上,自己如果不是很清楚请参照样子做。
离线sunxiaoming
只看该作者 4楼 发表于: 2006-03-08
我用的是tmake来生成makefile文件,呵呵,不知道和qmake有什么区别讷
离线wayd2001

只看该作者 5楼 发表于: 2008-07-10
请问怎么解决的亚,我也是这个问题
快速回复
限100 字节
 
上一个 下一个