Linux – qmake uses an incorrect Qt installation path on Linux

qmake uses an incorrect Qt installation path on Linux… here is a solution to the problem.

qmake uses an incorrect Qt installation path on Linux

I compiled qt (qt-everywhere-opensource-src-4.7.4) using:

./configure --prefix=/edrive/local/qt
gmake && gmake install

When I want to create a new project with qmake, create a makefile with the wrong path and point to the wrong binary and library directories:

> qmake -query "QT_INSTALL_PREFIX"
/edrive/local

In the makefile

Includes:

-I/edrive/local/include/QtCore
-I/edrive/local/include/QtGui
-I/edrive/local/include

Library:

-L/edrive/local/lib

User Interface:

/edrive/local/bin/uic

These are obviously wrong because qt is installed in /edrive/local/qt.

Is there a way to fix this other than manually modifying the qt config file?
Am I doing something wrong?

By the way, it’s choosing the right qmake:

> which qmake
/edrive/local/bin/qt/qmake

Solution

You can change the value in the following ways:

# qmake -set VARIABLE VALUE

i.e. in your case:

# qmake -set QT_INSTALL_PREFIX /edrive/local/qt

Although from your qmake location, you called the wrong qmake.
Try

/edrive/local/qt/bin/qmake -query "QT_INSTALL_PREFIX"

I feel like you also have 2 Qt installed.

Related Problems and Solutions