Friday, September 8, 2017

pkg_config and qmake

If you're developing an application with Qt which in turn relies on some library that uses the pkg-config tool, you can take advantage and simplify your Qt project file (.pro) as it will help avoiding hard-coded values for where to find headers and libraries for a particular package.
A common way to use pkg-config in makefiles is as follows:

gcc -o test test.c `pkg-config --libs --cflags glib-2.0`

in this case, a test application using glibs will get all the proper paths for include headers and libraries with such command. Now moving into a Qt project, it's even easier (no need to run external program pkg-config) as qmake will take care of all the required stuff given you ask it to rely on pkg-config for a desired package (in the example, the OpenCV library):

# includes and libraries for OpenCV
unix {
    CONFIG += link_pkgconfig
    PKGCONFIG += opencv
}

No comments:

Post a Comment