[Qt-interest] qmake: how to find Qt libraries / Qt home directory?

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Fri Jan 7 11:45:20 CET 2011


On 2011-01-07 ITS-CMT-SL-SFR-FIN-DEV Knoll Oliver, ITS-CMT-SL-SFR-FIN-DEV wrote:

> ...
> And I can even do a qmake -query QT_INSTALL_BINS which returns exactly what I
> am looking for.

Just for the record, this is my current solution:

  QT_BIN_DIR = $$system(qmake -query QT_INSTALL_BINS)
  QT_BIN_DIR = $$replace(QT_BIN_DIR, /, \\)

> However, this seems to confirm that there is really no such equivalent variable in
> qmake itself, which would be really convenient.

There are a few pitfalls and drawbacks though:

- first it looks terribly complicated, and since qmake -query always returns "Qt path
  delimiters" (/) - also on Windows! - I have to replace those with backslashes (\)
  on Windows

  For example, the following only works with \ in paths:

  XCOPY $${QT_BIN_DIR}\\QtCore4.dll  $${MY_DIST_DIR}

- Second, every time I run qmake with that *.pri file several times a Windows console
  pops up (I guess for each system() call once)


The last point is not so annoying when I run a build distribution step, but the point to note here is that the consoles also pop up each time I edit/save that *.pri file within Qt Creator (because Qt Creator re-parses those project files)! Ok, I can live with that, but it is definitively not an elegant solution.

And since qmake "knows" these directories anyway, why not provide them as build-in variables (assuming that these really do not exist), e.g. QMAKE_QT_BIN_DIR or something? 

As I wrote earlier already, qmake already provides $${QMAKE_LIBDIR_QT} which points to e.g. "C:/Qt/2010.05/qt/lib". But I am really looking for the directory where QtCore4.dll etc. is located and yes, with a simple ..\bin appended and replacing again the / with \ I could also find that desired directory. But why not provide it in the first place, or at least the "Qt base directory"? :)

I will open a suggestion issue in the Qt issue tracker...

Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22





More information about the Qt-interest-old mailing list