当前位置:编程学习 > wap >>

第一次写一个qt程序就出错了

就以hello world程序,系统是linux

#include <QtGui/QApplication>    //为什么我的头文件是在这里呢?
#include <QtGui/QLabel>          //

int main(int argc, char *argv[])
{
    QApplication app(argc,argv);
    QLabel *label = new QLabel("hello qt");
    label->show();

    return app.exec();
}


qmake -project
qmake hello.pro
钱两步都不出错
最后
make 出错了

g++  -o hello hello.o    -L/usr/lib64/qt-3.3/lib -lqt-mt -lXext -lX11 -lm
hello.o: In function `main':
/home/feng/workspace/QT/hello/hello.cpp:6: undefined reference to `QApplication::QApplication(int&, char**, int)'
hello.o: In function `QString':
/usr/include/QtCore/qstring.h:413: undefined reference to `QString::fromAscii_helper(char const*, int)'
hello.o: In function `main':
/home/feng/workspace/QT/hello/hello.cpp:7: undefined reference to `QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>)'
hello.o: In function `~QString':
/usr/include/QtCore/qstring.h:869: undefined reference to `QString::free(QString::Data*)'
/usr/include/QtCore/qstring.h:869: undefined reference to `QString::free(QString::Data*)'
collect2: ld 返回 1
make: *** [hello] 错误 1


求解是怎么回事? linux QT --------------------编程问答-------------------- 我无语啊。。。。。。。。。。。。。

为什么书里说的是qmake 命令?而我系统有qmake和qmake-qt4两个命令。
我用qmake-qt4命令重复上面的命令就得了!!!!!!!!!
无语啊!!! --------------------编程问答-------------------- 这个明显啊,是你的机子里有两个Qt 一个是Qt4 一个是Qt3.3
出于某些原因可能在 安装 Qt4的时候 qmake 并没有指向最新的 qmake-qt4,自己 Link一下就可以了。 --------------------编程问答-------------------- 的确,我安装系统时选择了安装编程环境,安装了QT3和QT4.

link我就不link了。自己写了个程序放到我的$HOME/bin/里,直接完成以上3步奏了
补充:移动开发 ,  Qt
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,