简体   繁体   中英

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

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???

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

I can't add a clarification comment to Nick's answer above, but that is the correct set of paths you need, I have tried with success using homebrew on osx 10.9.1.

If you want this to work with a GUI application such as an IDE, you need to add that path to /etc/launchd.conf .

See the following stack overflow comment: Setting environment variables in OS X?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM