First off: I use OS X 10.10 Yosemite and I do everything from Terminal, no XCode IDE or other GUI involved. I installed pkg-config version 0.28 from Homebrew.
I want to build some software which depends on Ogre 1.8. I built and installed OGRE (via CMAKE_INSTALL_PREFIX) to a custom location in my home directory.
The layout is as follows:
~/install/bin contains binaries
~/install/include contains OGRE include headers
~/install/lib contains static libraries, e.g. libOgreMainStatic.a
~/install/lib/pkgconfig contains *.pc files for Ogre, e.g. OGRE.pc
Before I add the path to PKG_CONFIG_PATH I get this:
$ pkg-config --variable pc_path OGRE
Package OGRE was not found in the pkg-config search path.
Perhaps you should add the directory containing `OGRE.pc'
to the PKG_CONFIG_PATH environment variable
No package 'OGRE' found
This is expected behavior. I then added ~/install/lib/pkgconfig
to my PKG_CONFIG_PATH like this:
$ export PKG_CONFIG_PATH=~/install/lib/pkgconfig
$ echo $PKG_CONFIG_PATH
/Users/myusername/install/lib/pkgconfig
Running
$ pkg-config --variable pc_path OGRE
<empty line while I expected the path to OGRE.pc>
again only shows an empty line but no error message however.
When I now run CMake for the software I want to build it says:
$ cmake .
<snip>
-- checking for module 'OGRE'
-- package 'OGRE' not found
What am I doing wrong? On Linux it works with the same commands.
The problem was that OGRE.pc referenced Freetype and a few other requirements which I had built from source. While Ogre was able to find them since they were in the path set by CMAKE_INSTALL_PREFIX
pkgconfig wasn't because they didn't provide *.pc files.
I discovered this by using this command:
Before fix:
$ pkg-config --libs OGRE
Package zziplib was not found in the pkg-config search path.
Perhaps you should add the directory containing `zziplib.pc'
to the PKG_CONFIG_PATH environment variable
Package 'zziplib', required by 'OGRE', not found
After fix:
$ pkg-config --libs OGRE
-L/Users/myusername/install/lib -L/Users/myusername/install/lib/OGRE -lOgreMainStatic -lpthread -lboost-thread-mt -lfreeimage