pkg-config and OSX 10.8, proper PKG_CONFIG_PATH? Missing .pc files?

Nick Desaulniers picture Nick Desaulniers · Aug 29, 2012 · Viewed 15.4k times · Source

I installed pkg-config with homebrew in OSX. I'm not sure what I should set my PKG_CONFIG_PATH to? Should it be a combination of /usr/include and /usr/local/include? Even if I use one or the other, I get an error about there not being any .pc files, which I take it would contain info used by pkg-config? Not sure what I'm doing wrong. Help appreciated.

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

Update: So maybe I'm asking two different questions. I just curled gsl and ran through the ./configure && make && sudo make install. And with an empty $PKG_CONFIG_PATH I actually got a hit with:

pkg-config --libs gsl  
-L/usr/local/lib -lgsl -lgslcblas -lm

But listing /usr/local/lib shows the gsl libs but no .pc files. How come pkg-config works for custom installed packages in OSX but not default installed ones???

Answer

Nick Desaulniers picture Nick Desaulniers · Mar 21, 2013

echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib" >> ~/.bashrc && source ~/.bashrc

to test with say glib:

brew install glib && pkg-config --libs --cflags glib-2.0

should get you the goods:

-I/usr/local/Cellar/glib/2.34.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.34.3/lib/glib-2.0/include -I/usr/local/Cellar/gettext/0.18.2/include  -L/usr/local/Cellar/glib/2.34.3/lib -L/usr/local/Cellar/gettext/0.18.2/lib -lglib-2.0 -lintl