![](/img/trans.png)
[英]pkg-config and OSX 10.8, proper PKG_CONFIG_PATH? Missing .pc files?
[英]pkg-config cannot find .pc files although they are in the path
我在 Mac OSX-Lion 上看到 pkg-config 有一个奇怪的问题。 为我下载的模块运行 python 设置时,我收到以下错误:
aspen:python toddysm$ sudo ./setup.py install
Password:
`pkg-config --libs --cflags cld` returns in error:
Package cld was not found in the pkg-config search path.
Perhaps you should add the directory containing `cld.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cld' found
The `cld` C++ library is absent from this system. Please install it.
但是,当检查 /usr/local/lib 文件夹时,我看到 libs 和 .pc 文件在 pkgconfig 子文件夹中
aspen:~ toddysm$ cd /usr/local/lib/
aspen:lib toddysm$ ls -al
total 2640
drwxr-xr-x 6 root wheel 204 Jul 2 17:38 .
drwxr-xr-x 9 root wheel 306 Jul 2 15:17 ..
-rwxr-xr-x 1 root wheel 1339516 Jul 2 17:38 libcld.0.dylib
lrwxr-xr-x 1 root wheel 14 Jul 2 17:38 libcld.dylib -> libcld.0.dylib
-rwxr-xr-x 1 root wheel 918 Jul 2 17:38 libcld.la
drwxr-xr-x 3 root wheel 102 Jul 2 17:38 pkgconfig
aspen:lib toddysm$ cd pkgconfig/
aspen:pkgconfig toddysm$ ls -al
total 8
drwxr-xr-x 3 root wheel 102 Jul 2 17:38 .
drwxr-xr-x 6 root wheel 204 Jul 2 17:38 ..
-rw-r--r-- 1 root wheel 279 Jul 2 17:38 cld.pc
使用命令行将 PKG_CONFIG_PATH 设置为指向 /usr/local/lib/ 没有帮助。 由于某种原因将其设置为 ~/.bash_profile 会使 pkg-config 无法识别为命令。
我的假设是我缺少一些依赖,但不确定是什么。 在 Linux 上尝试相同时,我缺少 Python Dev 包 python2.7-dev 但我不确定如何在 Mac 上检查它(是否存在)。
任何帮助将不胜感激。
您可以使用以下命令列出默认情况下pkg-config
查找的目录:
pkg-config --variable pc_path pkg-config
PKG_CONFIG_PATH
需要附加到变量的完整/usr/local/lib/pkgconfig
路径名。
需要export
环境变量才能对命令有用。 尝试
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ pkg-config --libs --cflags cld
似乎虽然PKG_CONFIG_PATH
设置正确,但 Python 脚本并没有选择它。 查看它在子进程中启动 pkg-config 的脚本,我不确定环境变量信息是否传递给子进程。 尽管如此,我还是通过将库和 .cp 文件复制到 /opt/local/lib/ 解决了这个问题,这是 pkg-config 所在的默认文件夹。
你可以尝试如下:
brew install pkg-config
brew install libvirt
它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.