PKG_CONFIG_PATH environment variable
Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.
What does this mean ?
Solution 1:
PKG_CONFIG_PATH
is a environment variable that specifies additional paths in which pkg-config
will search for its .pc files.
This variable is used to augment pkg-config's default search path. On a typical Unix system, it will search in the directories /usr/lib/pkgconfig
and /usr/share/pkgconfig
. This will usually cover system installed modules. However, some local modules may be installed in a different prefix such as /usr/local
. In that case, it's necessary to prepend the search path so that pkg-config can locate the .pc files.
The pkg-config
program is used to retrieve information about installed
libraries in the system. The primary use of pkg-config
is to provide the necessary details for compiling and linking a program to a library. This metadata is stored in pkg-config files. These files have the suffix .pc and reside in specific locations known to the pkg-config tool.
To check the PKG_CONFIG_PATH
value use this command:
echo $PKG_CONFIG_PATH
To set the PKG_CONFIG_PATH
value use:
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
or
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Solution 2:
To see where pkg-config (version 0.24 or later) searches for installed libraries by default, use the following command:
pkg-config --variable pc_path pkg-config
To add to that path, set the PKG_CONFIG_PATH
environment variable. The man file states PKG_CONFIG_PATH
is:
A colon-separated (on Windows, semicolon-separated) list of directories to search for .pc files. The default directory will always be searched after searching the path; the default is libdir/pkgconfig:datadir/pkgconfig where libdir is the libdir where pkg-config and datadir is the datadir where pkg-config was installed.
Solution 3:
The first answer is not technically explicit enough. From the man page (open a terminal, type man pkg-config
):
pkg-config
retrieves information about packages from special metadata files. These files are named after the package, and has a.pc
extension. On most systems,pkg-config
looks in/usr/lib/pkgconfig
,/usr/share/pkgconfig
,/usr/local/lib/pkgconfig
and/usr/local/share/pkgconfig
for these files. It will additionally look in the colon-separated (on Windows, semicolon-separated) list of directories specified by thePKG_CONFIG_PATH
environment variable.
So the pkg-config
program is not in the PKG_CONFIG_PATH
directory; however, if you install a library, for the information to use it in an automake
script to be accessible it needs to be in a directory pkg-config
is aware of.
Solution 4:
You're trying to build a piece of software, let's say Widget. Widget relies on another library, libcog for the sake of argument. Widget's build process (probably a configure script) is using pkg-config to determine how to use libcog. pkg-config doesn't know anything about libcog.
If libcog isn't installed, that's your problem. There is a good chance that a standard install of libcog will fix the problem. Depending on your system, you may need to install an addition "developer" version of the package; it often has "-devel" or "-dev" at the end, so if you install "libcog", you might also need to install "libcog-devel".
If libcog is installed, it's probably not installed in a way that pkg-config can find it. There is probably a libcog.pc file somewhere on your system. For the sake of argument, it's at /opt/cog/lib/pkgconfig/libcog.pc. In that case, you can tell pkg-config about it by setting the PKG_CONFIG_PATH to the directory holding libcog.pc. So in a Bourne shell or similar, something like
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/cog/lib/pkgconfig/
Once that's done, re-running the command that failed will hopefully work.
If libcog is installed, including the libraries and header files, and you don't have a libcog.pc file, things are going poorly. Presumably a standard install of libcog includes the information, or else Widget wouldn't rely on it. I'd first investigate reinstalling libcog. It is possible to manually create the libcog.pc file, but getting it right is difficult and highly specific to a given library.