[Solved] Qt paths in qmake / .pro



  • Hello,

    I'm using QDebug in debug mode and skipping it in release mode. I would like to avoid linking to Qt libraries for this project.

    In the .pro I've completed the INCLUDEPATH so that QDebug(.h) is found
    @
    release {
    DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_DEBUG
    CONFIG -= qt
    INCLUDEPATH += "......\QtSDK\Desktop\Qt\4.8.0\include" "......\QtSDK\Desktop\Qt\4.8.0\include\QtCore"
    }
    @

    It works well! Dependency Walker indicates that the executable generated does not depend on Qt dll's.

    The next step is to make this configuration cleaner:

    How to specify in a portable manner the path of the Qt include path?
    

    I would like to replace
    @ INCLUDEPATH += "......\QtSDK\Desktop\Qt\4.8.0\include" "......\QtSDK\Desktop\Qt\4.8.0\include\QtCore" @

    by something like
    @ INCLUDES += qt_include @

    to avoid refering to a particular installation path of the SDK that depends on the OS and the machine.

    Thanks


  • Moderators

    Why do you need this Qt in includepath? Just don't use it at all. For a debug build, wrap include in a ifdef:
    @
    #ifdef DEBUG
    #include <QtDebug>
    #endif
    @

    Or is it not working?



  • Hi Sierdzio,

    Thanks! It should be working but I have tens of "#include <QDebug>" and hundreds "qDebug() << ..." and having to test if DEBUG is defined at each call is cumbersome.



  • It looks to me like you always want to include the QDebug header, but not link the Qt library in release mode. So you do not want to wrap "#include <QDebug>" in a define.

    The QMake variable QMAKE_INCDIR_QT may be of help. It should point to ......\QtSDK\Desktop\Qt\4.8.0\include in your case. Try adding

    @
    INCLUDEPATH += $$QMAKE_INCDIR_QT $$QMAKE_INCDIR_QT/QtCore
    @

    to get rid of the hard-coded paths.



  • Fantastic, it works perfectly. Thanks!

    So the code looks (changed the conditional test)

    @
    CONFIG(release, debug|release) { #release mode only
    DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_DEBUG
    CONFIG -= qt
    INCLUDEPATH += $$QMAKE_INCDIR_QT $$QMAKE_INCDIR_QT/QtCore
    }
    @

    Marked thread as [Solved] :-)

    Thanks!



  • Excellent ;-)


Log in to reply
 

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