Qmake 5.0 not finding include files on OSX



  • Traditionally with qmake, I could start with a bunch of source files and just do this
    qmake -project
    qmake -makefile -spec maxc-g++
    make

    and an application would be built. With 5.0.0 all the QT widgets are not found. I get errors like
    main.cpp:1:25: error: QApplication: No such file or directory

    Even the standard QT Hello World implementation does this.

    The project files generated by the first qmake command haven't changed much, apart from the fact that the TARGET variable gets filled in now:

    ######################################################################

    Automatically generated by qmake (2.01a) Sun Dec 23 11:14:34 2012

    ######################################################################

    TEMPLATE = app
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .

    Input

    SOURCES += main.cpp
    macbook:qmake-omissions jeremy$ cat pro_5.0.0
    ######################################################################

    Automatically generated by qmake (3.0) Sun Dec 23 11:01:07 2012

    ######################################################################

    TEMPLATE = app
    TARGET = qmake-omissions
    DEPENDPATH += .
    INCLUDEPATH += .

    Input

    SOURCES += main.cpp

    So its clearly the makefile creation thats gone astray. The 5.0.0 generated makefile for a project containing just main.cpp is over 20k in length, double the length of the 4.8 equivalent.

    5.0.0 qmake comes up with this as an include path

    INCPATH = -I../../../Qt5.0.0/5.0.0/clang_64/mkspecs/macx-g++ -I. -I. -I../../../Qt5.0.0/5.0.0/clang_64/include -I../../../Qt5.0.0/5.0.0/clang_64/include/QtGui -I../../../Qt5.0.0/5.0.0/clang_64/lib/QtGui.framework/Versions/5/Headers -I../../../Qt5.0.0/5.0.0/clang_64/include/QtCore -I../../../Qt5.0.0/5.0.0/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers

    Missing the needed
    I../../../Qt5.0.0/5.0.0/clang_64/include/QtWidgets

    Anyone else seeing this? It seems a bit too fundamental to be generic to all OSX installations.


  • Moderators

    Includes are different in Qt 5. Please see porting guide. In general, widgets are now a new module (QT += widgets, #include <QtWidgets>), there are also other minor changes.

    Also, please consider using clang. g++ is broken, outdated and ugly on Mac.



  • Thanks for the comment sierdzio. I found two porting guides:
    http://qt-project.org/wiki/Transition_from_Qt_4.x_to_Qt5
    http://www.kdab.com/porting-from-qt-4-to-qt-5

    The former mentions adding a QT += widgets to .pro files, which does indeed fix the output of qmake -project. I don't see that as a porting step though, more as a workaround for a defect for the qmake included in qt5.

    Using clang simply produces shorter syntax errors, the include directories are still missing from the makefile. I notice the missing include directory also happens in Linux.

    Adding #include <QtWidgets> to the source does nothing to encourage qmake to add QT += widgets to the project.

    So I am thinking qmake got broken. If qmake -makefile now needs to see QT += widgets in the project, qmake -project should put that line in.

    Here is an example in case anyone else wants to play.

    ////// save this to main.cpp
    #include <QApplication>
    #include <QPushButton>
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QPushButton hello("Hello world!");
    hello.resize(100, 30);
    hello.show();
    return app.exec();
    }

    These commands should build an executable from the above.

    qmake -project
    qmake -makefile
    make


  • Moderators

    I see. This indeed seems to be a bug. I don't use the -project flag myself, so I had not hit it. Please consider filling a bug report on "JIRA":https://qt-project.org/wiki/ReportingBugsInQt and/ or pinging the development mailing list.


Log in to reply
 

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