我发现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文件夹时,我看到库和.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上检查这个包(是否有)。
任何帮助都将不胜感激。
发布于 2012-07-03 18:36:10
您可以使用以下命令列出默认情况下pkg-config查找的目录:
pkg-config --variable pc_path pkg-configPKG_CONFIG_PATH需要在变量后追加完整的/usr/local/lib/pkgconfig路径名。
发布于 2012-08-18 22:43:50
环境变量需要被export'ed才能对命令有用。
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ pkg-config --libs --cflags cld发布于 2012-07-04 06:36:07
看起来,尽管PKG_CONFIG_PATH被正确设置了,但Python脚本并没有使用它。查看脚本,它在一个子进程中启动pkg-config,我不确定环境变量信息是否传递给子进程。不过,我通过将库和.cp文件复制到/opt/local/lib/ ( pkg-config所在的默认文件夹)解决了这个问题。
https://stackoverflow.com/questions/11303730
复制相似问题