macos pkg-config 找不到 .pc 文件,尽管它们在路径中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11303730/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pkg-config cannot find .pc files although they are in the path
提问by toddysm
I am seeing a strange issue with pkg-config on Mac OSX-Lion. When running the python setup for module that I downloaded I receive the following error:
我在 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.
However when checking in the /usr/local/lib folder I see the libs and the .pc file is in the pkgconfig subfolder
但是,当检查 /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
Setting PKG_CONFIG_PATH to point to /usr/local/lib/ using the command line doesn't help. Setting it into ~/.bash_profile for some reason makes pkg-config unrecognizable as command.
使用命令行将 PKG_CONFIG_PATH 设置为指向 /usr/local/lib/ 没有帮助。由于某种原因将其设置为 ~/.bash_profile 会使 pkg-config 无法识别为命令。
My assumption is that I am missing some dependency but not sure what. When trying the same on Linux I was missing the Python Dev package python2.7-dev but I am not sure how to check for this on Mac (whether is there or not).
我的假设是我缺少一些依赖,但不确定是什么。在 Linux 上尝试相同时,我缺少 Python Dev 包 python2.7-dev 但我不确定如何在 Mac 上检查它(无论是否存在)。
Any help will be appreciated.
任何帮助将不胜感激。
回答by Brett Hale
You can list the directories pkg-config
looks in by default using:
您可以使用以下命令列出pkg-config
默认情况下的目录查找:
pkg-config --variable pc_path pkg-config
PKG_CONFIG_PATH
needs the full /usr/local/lib/pkgconfig
pathname appended to the variable.
PKG_CONFIG_PATH
需要/usr/local/lib/pkgconfig
附加到变量的完整路径名。
回答by Yasushi Shoji
Environment variables need to be export
'ed to be useful for commands. Try
环境变量需要export
对命令有用。尝试
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ pkg-config --libs --cflags cld
回答by toddysm
It seems that although the PKG_CONFIG_PATH
was properly set the Python script was not picking it up. Looking at the script it starts pkg-config in a subprocess and I am not sure whether the environment variable information is passed to the subprocess.
Nevertheless I solved the issue by copying the libraries and the .cp file to /opt/local/lib/ which is the default folder where pkg-config looks.
似乎虽然PKG_CONFIG_PATH
设置正确,但Python 脚本并没有找到它。查看它在子进程中启动 pkg-config 的脚本,我不确定环境变量信息是否传递给子进程。尽管如此,我还是通过将库和 .cp 文件复制到 /opt/local/lib/ 来解决这个问题,这是 pkg-config 所在的默认文件夹。
回答by xiaojueguan
you might try as follows:
你可以尝试如下:
brew install pkg-config
brew install libvirt
and it works for me.
它对我有用。