fbpx
Wikipedia

pkg-config

pkg-config is a computer program that defines and supports a unified interface for querying installed libraries for the purpose of compiling software that depends on them. 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 BSD, Microsoft Windows, macOS, and Solaris.

pkg-config
Original author(s)James Henstridge; rewritten by Havoc Pennington
Developer(s)Tollef Fog Heen / freedesktop.org
Initial release2000; 23 years ago (2000) or earlier
Stable release
0.29.2 / March 20, 2017; 6 years ago (2017-03-20)
Repositorygitlab.freedesktop.org/pkg-config/pkg-config
Written inC
Operating systemUnix-like
TypeProgramming tool
LicenseGNU GPL
Websitewww.freedesktop.org/wiki/Software/pkg-config/

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

The first implementation was written in shell.[1] Later, it was rewritten in C using the GLib library.[2]

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 the 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:

prefix=/usr/local exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${exec_prefix}/include   Name: libpng Description: Loads and saves PNG files Version: 1.2.8 Libs: -L${libdir} -lpng12 -lz Cflags: -I${includedir}/libpng12 

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:

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

pkg-config can be used by build automation software such as CMake.

Comparison with libtool

GNU Libtool is an alternative solution for managing the paths, dependencies, and required flags when linking to a library. There are a few differences in the approach taken:

  • pkg-config needs to be invoked explicitly for each dependency, while libtool wraps the call to the compiler.[3]
  • pkg-config has the --static option to distinguish between static and dynamic linking, for a static build the complete list of dependencies is passed to the compiler. libtool does not distinguish between static and dynamic linking, always passing the complete list of dependencies.
  • libtool is only useful if both the application and the library are built using libtool, while library written in any language can ship a .pc file.
  • pkg-config relies on the library search path, while libtool references libraries by their absolute path. This causes build failures with libtool when, for example, a library is moved from /lib to /usr/lib.

Alternative implementations

  • pkgconf – Implementation of pkg-config without depending on GLib[6]
  • PkgConfig – Pure-Perl Core-Only replacement for pkg-config
  • ruby-gnome/pkg-config – Implementation of pkg-config in Ruby

References

  1. ^ Havoc Pennington (4 June 2000). "Re: the *-config scripts". Retrieved 2020-01-22.
  2. ^ Havoc Pennington (23 July 2000). "pkg-config". Retrieved 2020-01-22.
  3. ^ "Autoconf, Automake, and Libtool: 10.3 Linking an Executable". sourceware.org. Retrieved 19 December 2021.
  4. ^ a b c d Found on spread of pkgconf but not spread of pkg-config on repology
  5. ^ a b c d Replacing pkg-config with pkgconf on arch-dev-public@lists.archlinux.org
  6. ^ default, instead of pkg-config, on Alpine Linux,[4]Arch Linux,[5]CentOS 8+,[4]Fedora,[5]FreeBSD,[5]Mageia 7+,[4]Manjaro[4] and NetBSD[5]

External links

  • pkg-config home at freedesktop.org
  • pkg-config(1) – Linux User Commands Manual
  • pkg-config(1) – OpenBSD General Commands Manual

config, computer, program, that, defines, supports, unified, interface, querying, installed, libraries, purpose, compiling, software, that, depends, them, allows, programmers, installation, scripts, work, without, explicit, knowledge, detailed, library, path, . pkg config is a computer program that defines and supports a unified interface for querying installed libraries for the purpose of compiling software that depends on them 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 BSD Microsoft Windows macOS and Solaris pkg configOriginal author s James Henstridge rewritten by Havoc PenningtonDeveloper s Tollef Fog Heen freedesktop orgInitial release2000 23 years ago 2000 or earlierStable release0 29 2 March 20 2017 6 years ago 2017 03 20 Repositorygitlab wbr freedesktop wbr org wbr pkg config wbr pkg configWritten inCOperating systemUnix likeTypeProgramming toolLicenseGNU GPLWebsitewww wbr freedesktop wbr org wbr wiki wbr Software wbr pkg config wbr It outputs various information about installed libraries This information may include Parameters flags for C or C compiler Parameters flags for linker Version of the package in questionThe first implementation was written in shell 1 Later it was rewritten in C using the GLib library 2 Contents 1 Synopsis 2 Comparison with libtool 3 Alternative implementations 4 References 5 External linksSynopsis EditWhen 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 the 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 prefix usr local exec prefix prefix libdir exec prefix lib includedir exec prefix include Name libpng Description Loads and saves PNG files Version 1 2 8 Libs L libdir lpng12 lz Cflags I includedir libpng12 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 gcc o test test c pkg config libs cflags libpng pkg config can be used by build automation software such as CMake Comparison with libtool EditGNU Libtool is an alternative solution for managing the paths dependencies and required flags when linking to a library There are a few differences in the approach taken pkg config needs to be invoked explicitly for each dependency while libtool wraps the call to the compiler 3 pkg config has the static option to distinguish between static and dynamic linking for a static build the complete list of dependencies is passed to the compiler libtool does not distinguish between static and dynamic linking always passing the complete list of dependencies libtool is only useful if both the application and the library are built using libtool while library written in any language can ship a pc file pkg config relies on the library search path while libtool references libraries by their absolute path This causes build failures with libtool when for example a library is moved from lib to usr lib Alternative implementations Editpkgconf Implementation of pkg config without depending on GLib 6 PkgConfig Pure Perl Core Only replacement for pkg config ruby gnome pkg config Implementation of pkg config in RubyReferences Edit Havoc Pennington 4 June 2000 Re the config scripts Retrieved 2020 01 22 Havoc Pennington 23 July 2000 pkg config Retrieved 2020 01 22 Autoconf Automake and Libtool 10 3 Linking an Executable sourceware org Retrieved 19 December 2021 a b c d Found on spread of pkgconf but not spread of pkg config on repology a b c d Replacing pkg config with pkgconf on arch dev public lists archlinux org default instead of pkg config on Alpine Linux 4 Arch Linux 5 CentOS 8 4 Fedora 5 FreeBSD 5 Mageia 7 4 Manjaro 4 and NetBSD 5 External links Editpkg config home at freedesktop org pkg config 1 Linux User Commands Manual pkg config 1 OpenBSD General Commands Manual Retrieved from https en wikipedia org w index php title Pkg config amp oldid 1146191269, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.