I have been installing a bunch of libraries lately from the GNOME sources on Mac. They use pkg-config.

Every time I run a configure, it complains that it can't find library XYZ, which I installed to /usr/local/lib. The only way I can complete the configure process is to reinstall the packages using MacPorts.

How can I get pkg-config to see the default /usr/local/lib? Setting PKG_CONFIG_PATH doesn't seem to work.

2 Answers 2


I figured this out. Apparently packages that use pkg-config create a .pc file in the highest-level directory that is created after untaring source code for library Y.

Then, if library Z complains that it cannot find library Y, and it uses pkg-config, set the PKG_CONFIG_PATH variable to point to the directory which contains the .pc file.

In my case, libxml++ relies on libxml2, so when configuring libxml++, I have to point the path to the .pc file created by libxml2:

export PKG_CONFIG_PATH=/Users/ryan/SVN/packages/libxml2-2.7.3/

Then configure works correctly.

  • strange how that would work as .pc is a file, not a path? however it that works for then great. Stuart Jul 24, 2009 at 19:31
  • 2
    Actually the correct notation is to provide the containing directory, not the filename itself.
    – ypnos
    May 18, 2010 at 13:48

you have to set PKG_CONFIG_PATH to exactly where the library is, such as xyz.so is not in /usr/lib but /usr/lib/xyz so you need to extend the path to include it...

export PKG_CONFIG_PATH = $PKG_CONFIG_PATH:/usr/lib/xyz


  • Ugh. So if there are multiple such libraries, I would need to specify the path to each of these libraries individually? Jul 24, 2009 at 17:55
  • Yes. On a typical unix systems user would install all their custom libraries to one single location, like /usr/local/ or ~/lib. Then pkgconfig would be more convenient to use ;)
    – ypnos
    May 18, 2010 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.