• 5332阅读
  • 4回复

编译出现错误,望达人看看是什么错误? [复制链接]

上一主题 下一主题
离线nashu
 
只看楼主 倒序阅读 楼主  发表于: 2007-12-16
— 本帖被 XChinux 执行加亮操作(2008-05-08) —
examplebase.o(.text+0x18): undefined reference to
`QWidget::QWidget[not-in-charge](QWidget*, char
const*, unsigned)'
离线XChinux

只看该作者 1楼 发表于: 2007-12-16
粘贴一下上下文吧
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线foxyz

只看该作者 2楼 发表于: 2007-12-17
一般如果出现这种错误undefined reference 表示你要么有用到的函数的源文件或者lib没有加入Makefile.
当然从你的错误来看恐怕是没有把QtGui的lib加进去?
离线bluedream373
只看该作者 3楼 发表于: 2007-12-18
可能是这个函数在头文件里面有定义,可是没有实现。
离线hatoyu

只看该作者 4楼 发表于: 2008-05-08
我的错误一样阿

程序

#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环境
快速回复
限100 字节
 
上一个 下一个