在OSX上出现"pkg-config脚本未找到"的错误提示

111

我正在尝试在我的Mac上安装一些软件,但是我一直收到同样的错误:

configure: error: The pkg-config script could not be found or is too old.  Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables XMEDCON_GLIB_CFLAGS
and XMEDCON_GLIB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See `config.log' for more details

我不太确定如何将pkg-config添加到PATH中。我在网上看到(请参见链接),应该添加以下内容:

显示如何设置PATH变量的链接

export PATH=$PATH:/opt/local/bin     # Fixed typo as mentioned in comment

这是我安装pkg-config的位置,但每次尝试使用./configure配置文件时仍然会出现错误。非常感谢任何帮助!


export PATH=$PATH:/opt/local/bin 中,您缺少一个冒号。这假定 /opt/local/bin/pkg-config 存在且是您想要的版本。 - tripleee
抱歉打错字了。问题是在将此输入终端后跟着执行"./configure"命令后,我仍然收到这个错误。有任何想法可能是什么问题吗? - Shinobii
which pkg-config 的输出是什么? - StvnW
"/opt/local/bin/pkgconfig/bin/pkg-config" 是我在 PATH 设置为 "/opt/local/bin/pkgconfig/bin" 时返回的内容。 - Shinobii
6个回答

201
对于Ubuntu/Debian操作系统, apt-get install -y pkg-config
对于Redhat/Yum操作系统, yum install -y pkgconfig
对于Archlinux操作系统, pacman -S pkgconf
对于MacOS操作系统, brew install pkg-config

17
请注意该问题是关于OSX的。 - Ali Seyedi
8
尽管如此,在Ubuntu上使用浏览器仍然可以使用Google,这也是我来到这里的原因。但是,和接受的答案建议的通过不安全连接curl运行任意代码相比,使用软件包管理器更为优越。 - ivarni
1
+1 给 @AliSeyedi:问题是关于OSX的。我相信大多数Linux用户都知道如何安装软件包,但在Mac上并不那么明显。 - Orabîg
4
当我在Ubuntu上执行此命令时,它需要管理员权限,即 sudo apt-get install -y pkg-config(值得一提)。 - Guy Avraham

59

对于我来说,(在OSX上)问题是通过执行以下操作解决的:

brew install pkg-config

如果您没有brew,请访问https://brew.sh。 - Zsolt Safrany

41

通过多次谷歌搜索,我得出了以下答案:

$ curl https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.tar.gz -o pkgconfig.tgz
$ tar -zxf pkgconfig.tgz && cd pkg-config-0.29
$ ./configure && make install

来自以下链接:以上显示的链接

感谢所有人的评论,很抱歉我对Linux / OSX一无所知!

按照上述方式操作解决了我上面提到的问题。


10
在Ubuntu 12.04上运行这些命令会出现错误:configure: error: 找不到先前安装的pkg-config或"glib-2.0 >= 2.16"。请将GLIB_CFLAGS和GLIB_LIBS设置为正确的值,或传递--with-internal-glib给configure以使用捆绑的副本。 - Drew Noakes
10
对于Ubuntu,您可以使用命令sudo apt-get install pkg-config进行安装。 - Aliza
这适用于Ubuntu 14.04.6 LTS,如果你想要0.29而不是默认的0.26(太旧无法交叉编译ffmpeg)。 - Camille Goudeseune
使用curl安装东西很可能会导致麻烦或在将来某个时候出现问题,并且无法自动更新。我建议使用Stephen Hsu的解决方案。 - Closed Limelike Curves

25

如果你遇到了这个错误:

configure: error: Either a previously installed pkg-config or "glib-2.0 >= 2.16" could not be found. Please set GLIB_CFLAGS and GLIB_LIBS to the correct values or pass --with-internal-glib to configure to use the bundled copy.

不要执行这个命令:

$ ./configure && make install

做这个:

./configure --with-internal-glib && make install

6
嗨,当我进行安装时,出现了错误:“找不到 x86_64 架构的符号”。 - White Philosophy
1
无法使用pkg-config。https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz版本0.29.2已经解决了这个问题。 - Stanley Wintergreen

2

0

MacOS用户

不幸的是,pkg-config在OS X中默认情况下不提供。以下是有关如何从源代码编译的一些注意事项。它假定您已安装Xcode。

  1. 下载并提取
curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
tar xfz pkg-config-0.28.tar.gz
配置和安装。
cd pkg-config-0.28
setenv CC /usr/bin/cc (for tcsh)
export CC=/usr/bin/cc (for bash)

2a) 如果您拥有超级用户权限

./configure --prefix=/usr/local CC=$CC --with-internal-glib
make
sudo make install

2b) 如果不是

./configure --prefix=$HOME/someplace/in/my/path CC=$CC --with-internal-glib
make
make install

来源:https://opensource.ncsa.illinois.edu/confluence/display/DESDM/Installing+pkg-config+from+source+for+OSX


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接