Is there a Qt install path variable that I can use in the .pro file? Is there a Qt install path variable that I can use in the .pro file? linux linux

Is there a Qt install path variable that I can use in the .pro file?


For Qt4 and Qt5, looks like $$[QT_INSTALL_LIBS] is what you want? Can't confirm first-hand this works though.

See https://forum.qt.io/topic/65778/qmake-and-qt-installation-root-directory/2 and http://doc.qt.io/qt-4.8/qmake-advanced-usage.html.


Another solution (may be not as fancy as above with $[QT_INSTALL_LIBS] but I used it already for quite a long time:

TEMPNAME = $${QMAKE_QMAKE}QTPATH = $$dirname(TEMPNAME) 

then you can reference it like this (for example to access some private headers) or to copy things:

INCLUDEPATH += $$QTPATH/../../Src/qtbase/src/sql/kernel


The variable QT_INSTALL_PREFIX seems to be what you want, but it highly depends on how Qt has been installed.

For more fine-tuning depending on the exact qt directory you're interested in, the following command will give you an exhaustive list of persistent properties of qt:

/path/to/qmake -query# Output# QT_INSTALL_PREFIX:/path/to/Qt# QT_INSTALL_ARCHDATA:...# ...

The already mentioned QT_INSTALL_LIBS is listed there for example. Once you find the variable corresponding to your usecase, you can use it in your .pro file as it was already mentioned, i.e. with $$[QT_INSTALL_PREFIX] for example.

Note: from the qmake documentation, squared brackets should be used for qmake properties ($$[])

Versions: tested with Qt 5.6.2 and qmake 3.0