qmake and QT_INSTALL_PREFIX. How can I select a new location for Qt library?

David Segonds picture David Segonds · May 27, 2009 · Viewed 19.2k times · Source

I am new to qmake and I am trying to build an existing application. Qt was originally installed in /usr/local/lib/Qt-4.3.5 and 'qmake -query QT_INSTALL_PREFIX' returns that path.

I have moved the Qt library to another location and the generated Makefiles are peppered with the /usr/local original path.

How can I force qmake to use the new location I selected without recompiling Qt?

Answer

Fabio Zadrozny picture Fabio Zadrozny · Nov 1, 2011

I was looking into this and found a way that works (in qt 4.7.2) by customizing qt with a qt.conf file.

In my case, I added a qt4-4.7.2/bin/qt.conf (It must be in the same place as the qmake executable)

With the following contents:

[Paths]
Prefix = c:/my_path/to/qt4-4.7.2

and the qmake -query started returning the proper paths!

See: http://doc.qt.io/qt-4.8/qt-conf.html for more details


[Update:] Since at least Qt 5.3.1 (tested with static versions of 5.3.1 and 5.5 on Windows 8) you can simply do

[Paths]
Prefix = ..

and deploy the Qt installation anywhere.