Neha Patil (Editor)

Pkg config

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Written in
  
C

Original author(s)
  
James Henstridge; rewritten by Havoc Pennington

Developer(s)
  
Tollef Fog Heen / freedesktop.org

Initial release
  
2000; 17 years ago (2000) or earlier

Stable release
  
0.29 / September 27, 2015; 17 months ago (2015-09-27)

Repository
  
anongit.freedesktop.org/pkg-config

pkg-config is a computer program that provides a unified interface for querying installed libraries for the purpose of compiling software from its source code. It allows programmers and installation scripts to work without explicit knowledge of detailed library path information. pkg-config was originally designed for Linux, but it is now also available for the various BSDs, Microsoft Windows, Mac OS X, and Solaris.

It outputs various information about installed libraries. This information may include:

  • Parameters for C or C++ compiler
  • Parameters for linker
  • Version of the package in question
  • The first implementation was written in shell. Later, it was rewritten in C using the GLib library.

    Synopsis

    When a library is installed (automatically through the use of an RPM, deb, or other binary packaging system or by compiling from the source), a .pc file should be included and placed into a directory with other .pc files (the exact directory is dependent upon your system and outlined in the pkg-config man page). This file has several entries.

    These entries typically contain a list of dependent libraries that programs using the package also need to compile. Entries also typically include the location of header files, version information and a description.

    Here is an example .pc file for libpng:

    This file demonstrates how libpng informs that its libraries can be found in /usr/local/lib and its headers in /usr/local/include, that the library name is libpng, and that the version is 1.2.8. It also gives the additional linker flags that are needed to compile code that uses this library.

    Here is an example of usage of pkg-config while compiling:

    References

    Pkg-config Wikipedia