[Qt-interest] pkg-config and QtCore

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Tue Jun 1 14:18:26 CEST 2010


Stefanos Antaris wrote on Tuesday, June 01, 2010 1:35 PM:

> I was just trying to built a program which needs pkg-config.Propably
> i have made a mistake on Qt libraries and pkg-config cannot find
> QtCore.

I am not sure whether Qt itself generates a pkg-config entry for itself - are you sure this is supported? Such that you can build an application which requires Qt and use pkg-config to find the Qt installation (that is your scenario, if I understood you correctly)? I have never heard of that feature (which does not mean that it does not exist ;)

What IS supported however is that you can use pkg-config within your *.pro files, as in:

// MyProject.pro
CONFIG += qt
QT += xml
...
CONFIG += link_pkgconfig
PKGCONFIG += ogg dbus-1

The statement CONFIG += qt tells qmake to generate the proper link statements with Qt. Default is QtCore and QtGui. With QT you can specify additional Qt modules such as network, opengl etc., see

  http://doc.trolltech.com/4.6/qmake-project-files.html#declaring-qt-libraries

And I think as long as the proper qmake version (check with qmake -v!) is in the PATH this should work automagically, that is qmake "knows" the location of the Qt libraries (they're encoded in the qmake binary - so as long as you installed/compiled Qt properly and did not move its location, that should work).

As for the pgk-config support: you can tell qmake to use pkg-config to locate OTHER 3rd-party libraries, such as ogg and dbus-1 etc.:

  http://doc.trolltech.com/4.6/qmake-project-files.html#configuration-features

I can confirm that this mechanism works just fine on Snow Leopard, this way my application links successfully against ImageMagick, which I have installed via "Mac Ports" (hence a proper pkg-config entry is generated during compilation of ImageMagick).


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





More information about the Qt-interest-old mailing list