Something about include file



  • yesterday I download and install QT-5.3 on my linux(ubuntukylin),today I try to compile my first QT-project.
    I write the code by VIM like like this :
    @#include<QApplication>
    #include<QLabel>
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QLabel *label = new QLabel("Hello Qt!");
    label->show();
    return app.exec();
    }@
    I save this file when I finished , and the file's path is /home/jxf/TestQt
    then commond:
    cd /home/jxf/TestQt
    qmake -project
    qmake TestQt.pro

    so far,everything is going well
    when I used last commond : make
    the system tell me,"fatal error: QApplication: No such file or directory",

    then I try to find answer in inter,and someone tell me put "QT += widgets" in TestQt.pro.

    I do like this and compile again,but system tell me "fatal error: Qlabel: No such file or directory" this time,

    others in inernet tell me modify source code file,
    #include<QtWidgets/QLabel> replace #include<QLabel>,
    but when I make ,system still tell me fatal error: Qlabel: No such file or directory

    How can I do....



  • Could you show TestQt.pro ?
    Did you run qmake to regenerate Makefile after you have changed TestQt.pro?



  • [quote author="andreyc" date="1402808566"]Could you show TestQt.pro ?
    Did you run qmake to regenerate Makefile after you have changed TestQt.pro?[/quote]
    Could you show TestQt.pro ?
    ls -l /home/jxf/testQt
    qt.cxx
    testQt.pro
    Makefile

    vim /home/jxf/testQt/testQt.pro

    TEMPLATE = app
    TARGET = testQt
    INCLUDEPATHPATH +=.
    #Input
    SOURCES +=qt.cxx
    QT += widgets

    Did you run qmake to regenerate Makefile after you have changed TestQt.pro?
    if I hadn't input "QT += widgets",system will tell me " fatal error: QApplication: No such file or directory" when I using commond "make".
    if I had input like source file,system will tell me "fatal error: Qlabel: No such file or directory".



  • I copied your files and it run without any errors.

    Is it possible that you have another version of Qt installed?
    Qt-4 that comes with Ubuntu for example.

    Try to run qmake from Qt-5.3 using full path.
    Something like this
    @
    $HOME/Qt/5.3/gcc_64/bin/qmake
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.