

What does this mean ?

  • 1
    I would almost ask this the same way except you could have asked for examples of the proper usage of PKG_CONFIG_PATH environment variable like "what is it and how do I use it?" It seems like the answers you got were trying to tell you this. I'm finding this show up a lot during ./configure when it fails to find dependencies. – Douglas G. Allen Oct 25 '14 at 4:08

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:


To set the PKG_CONFIG_PATH value use:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig


export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
| improve this answer | |
  • @NathanKidd Thanks for the reminder, comment deleted. The original error seems to have been resulted from a non-original author edit anyway. – Timothy Gu Aug 9 '17 at 7:22
  • @remram it looks like the errors are fixed now but your comment leaves people confused if they don't carefully examine the edit history. Could you check you're happy with current accuracy and perhaps delete the comment then? (And I'll delete mine.) – Nathan Kidd Aug 9 '17 at 13:49
  • @devav2 both export commands don't fix the issue – Shayan Feb 28 '18 at 13:45

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.

| improve this answer | |
  • 4
    a useful script will be echo $(pkg-config --variable pc_path pkg-config)${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH} – albfan Mar 5 '15 at 22:13
  • 5
    This is a great answer that helped me out. However, to clarify, you should say "To add to that path", rather than "To modify", as one can have a blank PKG_CONFIG_PATH and still have default searched directories, plus setting a non-blank value doesn't clear the defaults. – underscore_d Sep 13 '15 at 19:36
  • This answer was really useful to me, thanks! I was trying to figure out what the default search path for pkg-config was since mine is installed with Linuxbrew, so the default paths don't exist. Thanks! – mxplusb Sep 5 '18 at 18:39
  • This command is useful, on my Ubuntu the /usr/lib/x86_64-linux-gnu/pkgconfig directory is included in the output. I was just wondering this path is in the default search path. – Kemin Zhou Feb 19 at 23:15

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 the PKG_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.

| improve this answer | |
  • 1
    The key phrase appears to be "on most systems". On my Debian, for instance, we get /usr/local/lib/x86_64-linux-gnu thrown in as an automatic search location for free (with an empty PKG_CONFIG_PATH), and indeed, lots of .pc files - notable including GTK+ et al. - live there. The reason for this is to enable multi-architecture availability of a package simultaneously, as outlined here: askubuntu.com/questions/449348/… – underscore_d Sep 13 '15 at 19:28
  • (can't edit anymore) @GrandAdmiral in an answer further down this page showed how to check the default paths that pkg-config will search on your system: askubuntu.com/a/373217/436580 – underscore_d Sep 13 '15 at 19:34

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.

| improve this answer | |
  • 4
    One thing though - what if PKG_CONFIG_PATH is defined - this will overwrite it correct? – NoBugs Oct 31 '15 at 15:26
  • 1
    @NoBugs good catch, I've edited the answer (several years later!) to append it instead. – Joe Malt Aug 30 '18 at 20:27
  • Thank you that really helped, i run it like this for making cef build : export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/share/pkgconfig/ and export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/x86_64-linux-gnu/pkgconfig/ – Vipertecpro Jan 12 at 6:05

I looked at the man-page on my 64-bit system and got a bit confused. It said in one line:

pkg-config retrieves information about packages from special metadata files. These files are named after the package, with the extension .pc. By default, pkg-config looks in the direc‐ tory prefix/lib/pkgconfig for these files; it will also look in the colon-separated (on Windows, semicolon-separated) list of directories specified by the PKG_CONFIG_PATH environment vari‐ able.

I had assumed that it alwas looks in the directories lib/pkgconfig. Turns out its the directories themselves. In my case, I was trying to compile the hello world gtk tutorial. I locate the file i want e.g.

locate gtk | grep '\.pc'

Among the results are:


Finally was to do an export.

export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/
| improve this answer | |
  • 1
    +1 for pointing out how the man page is oversimplifying for modern, multi-architecture-capable systems. I was confused for a while because, on Debian 8 x86, pkg-config already looks in the x86_64 folder (without anything in PKG_CONFIG_PATH). I'm not sure how this was incorporated, but the command line to probe this shown by @GrandAdmiral indicates it's controlled by the --variable pc_path that is set (somehow!) for pkg-config's own package. – underscore_d Sep 13 '15 at 19:48

It seems to me that most of the answers have too much information than needed.

The software that one installs may (and usually does) rely on some libraries and/or headers and the System uses pkg-config to find them.

Said so, pkg-config looks for this files in pre-defined (default) system's directories. Those folders are "prefix". E.g. a library that has prefix /usr/local is expected to have headers in /usr/local/include, and the library itself will be in /usr/local/lib. pkg-config however looks for libraries also in directory listed in the environment variable PKG_CONFIG_PATH.

Then if you install software outside the default list of folders you had to "adjust" the list, namely add your directories to PKG_CONFIG_PATH

$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:<your-directory>

For more info, you can look here and here

| improve this answer | |
  • PKG_CONFIG_PATH specifies additional directories in which to search for only yourPkg.pc (pkg-config specification) files. It does not affect pkg-specific things like library search directories. – underscore_d Sep 13 '15 at 19:43

It means you're trying to build something from source, and it can't find all of the dependencies it needs. The pkg-config script it uses to find the development files for those libraries, outputs this message.

| improve this answer | |

I was trying to install the latest version of axel and I ran ./configure and I got this:

configure: error: Package requirements (openssl) were not met:

No package 'openssl' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables SSL_CFLAGS
and SSL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

So I tried:

$ pkg-config --cflags openssl

and I got:

Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `openssl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'openssl' found

As obvious I had openssl installed (sudo apt-get install openssl) But on the above output as you can see it states "No package 'openssl' found". So to make sure I did:

find / -type f -name "*.pc" |& grep -iv permission | grep openssl

Turns out I need some other package for sure, so a little googling and I found that I had to install this package:

sudo apt-get install libssl-dev

And all this had nothing to do with changing pkg-config path env variable.

| improve this answer | |

Those who are using https://github.com/confluentinc/confluent-kafka-go

Please follow the installing librdkafka

  1. git clone https://github.com/edenhill/librdkafka.git
  2. cd librdkafka
  3. ./configure --prefix /usr
  4. make
  5. sudo make install

Now you can use go install/ go run go build

| improve this answer | |

Your Answer

