我的错误一样阿
程序
#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();
}
编译出错信息
g++ -Wl,--no-undefined -o ../bin/hello main.o -L/usr/lib -lQtCore -lpthread
main.o: In function `main':
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:46: undefined reference to `QApplication::QApplication(int&, char**, int)'
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:48: undefined reference to `QWidget::QWidget(QWidget*, QFlags<Qt::WindowType>)'
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:49: undefined reference to `QLabel::QLabel(QWidget*, QFlags<Qt::WindowType>)'
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:50: undefined reference to `QLabel::setText(QString const&)'
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:52: undefined reference to `QApplication::exec()'
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:52: undefined reference to `QLabel::~QLabel()'
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:52: undefined reference to `QLabel::~QLabel()'
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:52: undefined reference to `QApplication::~QApplication()'
/home/hatoyu/Desktop/hatoyu/C/k/hello/src/main.cpp:52: undefined reference to `QApplication::~QApplication()'
希望有人帮忙解惑
我用kdevelop 开发的 ubuntu环境