22

在 Mac OS X 1.7.5 / Lion 上

我正在尝试使用自制软件安装 cairo 包

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

当我尝试编译我的代码时,我仍然得到这个:

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

所以我相应地调整了我的 PKG_CONFIG_PATH

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

(来源.bash_profile)

尝试再次编译,但我得到完全相同的错误。

验证该文件是否存在于该 pkgconfig 目录中......它是。

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

关于这里出了什么问题的任何线索?

更新

cairo.pc 位于我系统中的太多地方。我尝试使用我的 pgg 配置路径中的每个位置都没有成功

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
4

5 回答 5

13

注意:仅适用于 Ubuntu。

解决我的问题更容易。只是没有正确安装 Ubuntu 依赖项,您可以在此处找到说明:

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

这对我有用:

sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
于 2014-06-26T20:55:04.520 回答
6

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

解决了我的问题

于 2013-10-10T22:19:40.087 回答
4

我在优胜美地遇到了这个问题,并通过重新安装 cairo 解决了这个问题。

$ brew unlink cairo
Unlinking /usr/local/Cellar/cairo/1.14.2... 30 symlinks removed
$ brew install cairo
于 2016-03-10T20:40:30.377 回答
3

您可以使用PKG_CONFIG_PATH相同的。IE:

PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.12.16/lib/pkgconfig ./configure ....
于 2014-04-27T07:48:24.817 回答
1

要调试和修复此问题:

  1. 运行pkg-config --libs cairo。如果它显示以下错误,则问题仍然存在。

    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. 要查找 使用的默认搜索路径pkg-config,请运行:

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

    如果您在步骤 (1) 中仍有错误,则输出将不包括包含cairo.pc.

  3. 找到包含cairo.pc. 如果您cairo使用 brew 安装,通常它在 下/opt,您可以在其中运行 find /opt -name cairo.pc

  4. PKG_CONFIG_PATH使用包含的目录设置env 变量cairo.pc。您只能这样做一次:

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

    喜欢PKG_CONFIG_PATH=<path containing cairo.pc> pkg-config --libs cairo,或导出环境

    export PKG_CONFIG_PATH=<path containing cairo.pc>
    

    然后运行你的命令。

于 2021-08-09T00:22:54.333 回答