3

On Mac OS X 1.7.5 / Lion

I am trying to install cairo package using homebrew

brew install cairo => PASSED

==> Downloading http://cairographics.org/releases/cairo-1.12.16.tar.xz
Already downloaded: /Library/Caches/Homebrew/cairo-1.12.16.tar.xz
==> ./configure --prefix=/usr/local/Cellar/cairo/1.12.16 --with-x --enable-gobject=yes
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.

Mac OS X already provides this software in versions before Mountain Lion.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/cairo/lib
    CPPFLAGS: -I/usr/local/opt/cairo/include

==> Summary
🍺  /usr/local/Cellar/cairo/1.12.16: 105 files, 8.0M, built in 2.5 minutes

When I try to compile my code I still get this:

+++ Precompile
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
Package 'cairo', required by 'pangocairo', not found

So I adjusted my PKG_CONFIG_PATH accordingly

 PKG_CONFIG_PATH=/usr/local/opt/cairo/lib/pkgconfig/:/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig/:

(source .bash_profile)

Tried to compile again, but I get the exact same error.

Verified that the file was present in that pkgconfig directory ... it is.

ls /usr/local/opt/cairo/lib/pkgconfig/ 
cairo-fc.pc           cairo-gobject.pc      cairo-png.pc          cairo-quartz-font.pc  cairo-script.pc       cairo-xcb-shm.pc      cairo-xlib-xrender.pc cairo.pc
cairo-ft.pc           cairo-pdf.pc          cairo-ps.pc           cairo-quartz.pc       cairo-svg.pc          cairo-xcb.pc          cairo-xlib.pc

Any leads on what is going wrong here?

UPDATE

cairo.pc is located in too places in my system. I have tried using each location in my pgg config path without success

find /usr -name cairo.pc 
/usr/local/Cellar/cairo/1.12.16/lib/pkgconfig/cairo.pc
/usr/X11/lib/pkgconfig/cairo.pc

pkg-config --variable pc_path pkg-config
/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig

I notice that pkg-config is still not looking for .pc in the correct folder despite the fact that my environment variable has the correct paths (?) (PKG_CONGIG_PATH)

2
  • 1
    Try adding /opt/X11/lib/pkgconfig to PKG_CONFIG_PATH. I don't have any Cairo-dependent code to test this with, but I think it might work. Oct 10, 2013 at 20:35
  • I have tried that. This is puzzling. I just can't figure out why it's not seeing the cairo.pc, it's there. Is there a way to add a path to the pc_path variable (pkg-config) ...?
    – zabumba
    Oct 10, 2013 at 20:54

2 Answers 2

2
ln -s /usr/local/Cellar/cairo/1.12.16/lib/pkgconfig/cairo.pc /usr/local/lib/pkgconfig/cairo.pc

solved my problem.

1
  • I don't have Cellar folder under /usr/local/ path, And libcairo2 is installed!
    – Dr.jacky
    Jan 17, 2016 at 8:01
0

I just came across this problem and was able to solve it ( so far, at least ).

This formula is keg-only: so it was not symlinked into /usr/local.

From what I understand, this means that cairo was already installed by your system ( in fact, it is installed in /usr/X11 ), and Homebrew didn't want to mess with it. I can only assume that it has to do with ensuring the pre-existing packages find the right versions. As explained at the Homebrew FAQ: "We don’t do this for stupid reasons".

Homebrew has a tool link, which is shorthand for what your answer was.

$ brew link cairo --force

We need to pass --force in this case, it isn't typically necessary. Brew also has unlink, which is nice.

I came across another problem, which I don't think is too far off topic. Cairo depended upon files that are in my /usr/X11 folder only, which meant that link would not work. Now is time to export PKG_CONFIG_PATH.

$ export PKG_CONFIG_PATH=/usr/x11/lib/pkgconfig

However, this caused a different problem, pkgconfig was now finding the Cairo inside /usr/x11 before the Cairo that I had installed ( and manually linked to ) via brew. In order to finally get pkg-config --cflags gtkmm-3.0 working, I had to ensure that PKG_CONFIG_PATH looked at /usr/local/lib/pkgconfig first:

$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/usr/X11/lib/pkgconfig

You must log in to answer this question.

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