Get Package Version using pkg-config

Get Package Version using pkg-config

The pkg-config tool is commonly used to get information about installed packages, including compiler and linker options, and version details. When working with multiple dependencies, it is often necessary to determine the exact version of a specific package to ensure compatibility or troubleshoot build issues. This tutorial explains how to get package version using pkg-config.

To retrieve the version of an installed package, the --modversion option is used along with the package name. For instance, the command below returns the version of the libcrypt package:

pkg-config --modversion libcrypt

Output example:

4.4.27

If the specified package is not available in the pkg-config search path, an error message is shown instead of version information. This typically indicates that the corresponding development files are not installed or that the .pc file cannot be found in the configured pkg-config directories.

Leave a Comment

Cancel reply

Your email address will not be published.