Next: , Previous: , Up: The Macros  



AX_HAVE_QT [--with-Qt-dir=DIR] [--with-Qt-lib-dir=DIR] [--with-Qt-lib=LIB]
AX_HAVE_QT [--with-Qt-include-dir=DIR] [--with-Qt-bin-dir=DIR] [--with-Qt-lib-dir=DIR] [--with-Qt-lib=LIB]


Searches common directories for Qt include files, libraries and Qt binary utilities. The macro supports several different versions of the Qt framework being installed on the same machine. However, without options the macro will only look for a working Qt5 installation in $PATH.

By use of one or more options a different library, such as a Qt4 installation, may be selected. There are two different sets of options. Both sets contain the option –with-Qt-lib=LIB which can be used to force the use of a particular version of the library file when more than one are available. LIB must be in the form as it would appear behind the "-l" option to the compiler. Examples for LIB would be "qt-mt" for the multi-threaded version and "qt" for the regular version.

In addition to this, the first set consists of an option –with-Qt-dir=DIR which can be used when the installation conforms to Trolltech’s standard installation, which means that header files are in DIR/include, binary utilities are in DIR/bin and the library is in DIR/lib. The second set of options can be used to indicate individual locations for the header files, the binary utilities and the library file, in addition to the specific version of the library file.

The following shell variable is set to either "yes" or "no":


Additionally, the following variables are exported:


which respectively contain an "-I" flag pointing to the Qt include directory (and "-DQT_THREAD_SUPPORT" when LIB is "qt-mt"), link flags necessary to link with Qt and X, the name of the meta object compiler and the user interface compiler both with full path, and finally the variable QTDIR as Trolltech likes to see it defined (if possible).

Example lines for

  MOC      = @QT_MOC@

After the variables have been set, a trial compile and link is performed to check the correct functioning of the meta object compiler. This test may fail when the different detected elements stem from different releases of the Qt framework. In that case, an error message is emitted and configure stops.

No common variables such as $LIBS or $CFLAGS are polluted.


–with-Qt-dir=DIR: DIR is equal to $QTDIR if you have followed the installation instructions of Trolltech. Header files are in DIR/include, binary utilities are in DIR/bin and the library is in DIR/lib.

–with-Qt-include-dir=DIR: Qt header files are in DIR.

–with-Qt-bin-dir=DIR: Qt utilities such as moc and uic are in DIR.

–with-Qt-lib-dir=DIR: The Qt library is in DIR.

–with-Qt-lib=LIB: Use -lLIB to link with the Qt library.

If some option "=no" or, equivalently, a –without-Qt-* version is given in stead of a –with-Qt-*, "have_qt" is set to "no" and the other variables are set to the empty string.

Source Code

Download the latest version of ax_have_qt.m4 or browse the macro’s revision history.


Copyright © 2008 Bastiaan Veelo

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.

Next: , Previous: , Up: The Macros