Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Using pkg-config with qmake

From Wiki
Jump to: navigation, search
Article Metadata
Compatibility
Platform(s): Maemo
Symbian
Article
Keywords: Qt, qmake, Maemo
Created: gnuton (16 Jun 2010)
Last edited: hamishwillee (24 Jul 2012)

Contents

Using pkg-config with qmake

Preface: Who has to read this page?

People who want to add external libs to their Qt applications.

What's pkg-config

pkg-config is a helper tool used when compiling applications and libraries. It helps you insert the correct compiler options on the command line. So, for instance, an application can use

gcc -o test test.c $(pkg-config --libs --cflags glib-2.0)

rather than hard-coding the location of libs and include files. Manual page is to be found at pkg-config.

How pkg-config works

This utility takes data from .pc files in the /usr/lib/pkgconfig/ directory. Those files are installed by any library development package (eg: libsqlite3-dev).

 [sbox-FREMANTLE_ARMEL: ~] > dpkg -L libsqlite3-dev
 /.
 /usr
 /usr/include
 /usr/include/sqlite3.h
 /usr/include/sqlite3ext.h
 /usr/share
 /usr/share/doc
 /usr/share/doc/libsqlite3-dev
 /usr/share/doc/libsqlite3-dev/changelog.Debian.gz
 /usr/share/doc/libsqlite3-dev/README
 /usr/share/doc/libsqlite3-dev/copyright
 /usr/lib
 /usr/lib/libsqlite3.a
 /usr/lib/pkgconfig
 /usr/lib/pkgconfig/sqlite3.pc
 /usr/lib/libsqlite3.so

Which libs are managed by pkg-config

Usually every linux/Maemo library is managed by pkg-config and it appears in the list of managed packages:

 pkg-config --list-all

How to use pkg-config with qmake

Qt Project files (.pro) contain several variables used by the compiler, such as LIBS and INCLUDE. These variables contain the name and the location of the library required by the linker and the location of the include files used by the compiler.

When qmake creates a Makefile, it takes into account the predefined value of LIBS and INCLUDE coming from a Qt mkspec. The mkspec files are platform specific and they are stored in /usr/share/qt4/mkspecs/platform_name.

Anyway, Mkspecs files just keep Qt libs data. Therefore, a developer who wants to add new libraries has to tell to the compiler where the new libs are located.

This can be easily done by adding 2 lines to the project file:

unix {
    CONFIG += link_pkgconfig
    PKGCONFIG += <pc_file_without_extension>
}
This page was last modified on 24 July 2012, at 02:11.
260 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×