- 论坛徽章:
- 0
|
菜鸟刚接触QT, 按<<c++ GUI programming with Qt3>>写了个hello Qt!
如下:
#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char *argv[])
{
QApplication app (argc, argv);
QLabel *label = new QLabel("Hello Qt!", 0);
app.setMainWidget(label);
label->show();
return app.exec();
}
在make 时出现很多 undefined reference 报错, 请帮忙!!!!
[root@ws qt]# make
g++ -c -pipe -Wall -W -O2 -g -march=i386 -mcpu=i686 -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o hello.o hello.cpp
g++ -o qt hello.o -L/usr/X11R6/lib -lXext -lX11 -lm
hello.o(.text+0x32): In function `main':
/root/qt/hello.cpp:6: undefined reference to `QApplication: Application(int&, char**)'
hello.o(.text+0x41):/root/qt/hello.cpp:7: undefined reference to `QString: String(char const*)'
hello.o(.text+0x6d):/root/qt/hello.cpp:7: undefined reference to `QLabel: Label(QString const&, QWidget*, char const*, unsigned int)'
hello.o(.text+0x7f): In function `main':
/usr/lib/qt-3.3/include/qstring.h:847: undefined reference to `QString::shared_null'
hello.o(.text+0x89):/usr/lib/qt-3.3/include/qstring.h:848: undefined reference to `QStringData::deleteSelf()'
hello.o(.text+0x95): In function `main':
/root/qt/hello.cpp:8: undefined reference to `QApplication::setMainWidget(QWidget*)'
hello.o(.text+0xa :/root/qt/hello.cpp:10: undefined reference to `QApplication::exec()'
hello.o(.text+0xb2):/root/qt/hello.cpp:10: undefined reference to `QApplication::~QApplication()'
hello.o(.text+0xe4):/root/qt/hello.cpp:10: undefined reference to `QApplication::~QApplication()'
hello.o(.text+0x10c): In function `main':
/usr/lib/qt-3.3/include/qstring.h:847: undefined reference to `QString::shared_null'
hello.o(.text+0x116):/usr/lib/qt-3.3/include/qstring.h:848: undefined reference to `QStringData::deleteSelf()'
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+0x1 : 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+0x2 : undefined reference to `QGList::write(QDataStream&, void*) const'
hello.o(.gnu.linkonce.r._ZTI6QGList+0x : undefined reference to `typeinfo for QPtrCollection'
collect2: ld returned 1 exit status
make: *** [qt] Error 1 |
|