Forrest logo
back to the pkg-config tool

pkg-config:tldr:5a2d5

pkg-config: Get the list of libraries and their dependencies.
$ pkg-config --libs ${library1 library2 ---}
try on your machine

The command pkg-config --libs ${library1 library2 ---} is used to retrieve the compilation flags and linker flags for one or multiple libraries installed on a system.

Here is a breakdown of the command:

  • pkg-config: It is a command-line tool that retrieves information about installed libraries including their compilation and linker flags.

  • --libs: It is the option used to specify that you want the linker flags (i.e., the libraries) for the specified libraries.

  • ${library1 library2 ---}: It specifies the libraries for which you want to retrieve the linker flags. You can replace library1, library2, etc. with the actual names of the libraries you're interested in. If you have multiple libraries, you can list them with spaces in between.

For example, if you want to retrieve the linker flags for the libraries libfoo and libbar, the command would be:

pkg-config --libs libfoo libbar

The output of the command will be the linker flags needed to compile and link against the specified libraries. These flags are often used in compilation commands to ensure that the necessary libraries are linked correctly.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the pkg-config tool