22

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
zabumba
  • 12,172
  • 16
  • 72
  • 129

5 Answers5

14

NOTE: only for Ubuntu.

Solving my problem was easier. The Ubuntu dependencies were just not installed properly, and you can find instructions here:

https://github.com/LearnBoost/node-canvas/wiki

This is what worked for me:

sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
Milimetric
  • 13,411
  • 4
  • 44
  • 56
6

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

resolved my issue

Graham Swan
  • 4,818
  • 2
  • 30
  • 39
zabumba
  • 12,172
  • 16
  • 72
  • 129
  • 1
    Hi my issue is similar to yours only when I execute your command it says that the file already exist and when I try to build install rrdtool (which uses cairo) it still can't find it in the pkgconfig. Was there a set order in which I should have run all your commands ? Is there anything else you might have done that might get me to the desired result ? – AKFourSeven Apr 03 '15 at 12:34
  • I don't have Cellar folder under /usr/local/ path, And libcairo2 is installed. – Dr.jacky Jan 17 '16 at 08:01
4

I had this problem on Yosemite, and fixed it by reinstalling cairo.

$ brew unlink cairo
Unlinking /usr/local/Cellar/cairo/1.14.2... 30 symlinks removed
$ brew install cairo
Ian
  • 11,280
  • 3
  • 36
  • 58
3

You can use PKG_CONFIG_PATH for the same. I.e.:

PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.12.16/lib/pkgconfig ./configure ....
Mureinik
  • 297,002
  • 52
  • 306
  • 350
1

To debug & fix this:

  1. Run pkg-config --libs cairo . If it says the error below, then the issue still persist.

    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
    No package 'cairo' found
    
  2. To find the default search path used by pkg-config, run:

    pkg-config --list-all --debug 2>&1 > /dev/null |  grep 'Scanning directory'
    

    If you still have error at step (1), the output wouldn't include the directory containing cairo.pc.

  3. Find the directory containing cairo.pc. If you install cairo using brew, usually it's under /opt, in which you can run find /opt -name cairo.pc

  4. Set PKG_CONFIG_PATH env variable with the directory containing cairo.pc. You can do this for one time only:

    PKG_CONFIG_PATH=<path containing cairo.pc> <your command>
    

    like PKG_CONFIG_PATH=<path containing cairo.pc> pkg-config --libs cairo, or export the env

    export PKG_CONFIG_PATH=<path containing cairo.pc>
    

    then run your command.

cakraww
  • 2,493
  • 28
  • 30