Package cairo was not found in the pkg-config search path
Asked Answered
F

5

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
Fingerbreadth answered 10/10, 2013 at 14:36 Comment(0)
V
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++
Verda answered 26/6, 2014 at 20:55 Comment(4)
When you downvote, please leave a comment about what didn't work so we can improve the answer. Simply downvoting is not useful for anyone. – Verda
apt-get is not for mac – Rapparee
Right, for mac I don't know, but I imagine it either works to install the equivalent of those libraries or the problem is entirely different. – Verda
Not really. There is no direct equivalent of those packages in mac – Stringent
F
6

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

resolved my issue

Fingerbreadth answered 10/10, 2013 at 22:19 Comment(2)
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 ? – Christology
I don't have Cellar folder under /usr/local/ path, And libcairo2 is installed. – Cavender
C
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
Chirk answered 10/3, 2016 at 20:40 Comment(0)
A
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 ....
Aguilar answered 27/4, 2014 at 7:48 Comment(0)
F
2

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.

Fiorin answered 9/8, 2021 at 0:22 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.