I have installed some libraries with Homebrew but if I use pkg-config it does not find them because there are missing .pc files.

For example, if you do:

brew install opencv

and, after it is installed:

pkg-config --libs opencv

I get this error:

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

This error is caused because Homebrew does not create any opencv.pc.

Is there a way to configure Homebrew to create the .pc files so that all packages installed with brew can be found by pkg-config?


Check with brew ls opencv that there is no opencv.pc installed. I tried it and I have one. If you don't get one, then there is a bug in the package.

Otherwise, check that you are using the correct Homebrew pkg-config. Check with which pkg-config and ls -l $(which pkg-config) where it is coming from.

  • Thanks! this led me to report a bug in the webkitgkt package. Dec 8 '15 at 12:18

This post fixed it for me. It explains how to set a missing environment variable for pkg-config that points to all the installed packages.


  • 2
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
    – grg
    Dec 14 '17 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .