#include <QtGui/QApplication>
#include <QtGui/QWidget>
#include <QtGui/QLabel>
#include <QtCore/QTextCodec>
int main (int argc, char *argv[])
{
QApplication app(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
QWidget* pWidget = new QWidget;
QLabel label(pWidget);
label.setText(QObject::tr("同一个世界,同一个梦想!"));
pWidget->show();
return app.exec();
}
这是我在opensuse10.2中,用kdevelop3.5写的一个简单的程序,是基于qt4.3.2编写的
可是我编译的时候出现了下列的提示:
d '/home/wolf841128/hello' && gmake -k
cd src/ && gmake -f Makefile
正在编译 main.cpp (g++)
正在连接 ../bin/hello (g++)
main.o: In function `main':
main.cpp:(.text+0x31): undefined reference to `QApplication::QApplication(int&, char**, int)'
main.cpp:(.text+0x95): undefined reference to `QWidget::QWidget(QWidget*, QFlags<Qt::WindowType>)'
main.cpp:(.text+0xb2): undefined reference to `QLabel::QLabel(QWidget*, QFlags<Qt::WindowType>)'
main.cpp:(.text+0xe4): undefined reference to `QLabel::setText(QString const&)'
main.cpp:(.text+0x111): undefined reference to `QApplication::exec()'
main.cpp:(.text+0x11b): undefined reference to `QLabel::~QLabel()'
main.cpp:(.text+0x126): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0x141): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0x16b): undefined reference to `QLabel::~QLabel()'
collect2: ld returned 1 exit status
gmake[1]: *** [../bin/hello] 错误 1
gmake[1]: 由于错误目标“first”并未重新创建。
gmake: *** [sub-src-make_default] 错误 2
gmake: 由于错误目标“first”并未重新创建。
*** 退出状态:2 ***
请各位高手指点一下,是什么地方出现了问题啊
我的qt4安装在/usr/local/Trolltech/Qt-4.3.2中,我整好长时间了,请各位帮帮忙吧,在这里谢谢了