使用 pkg-config 宏 PKG_CHECK_MODULES 失败 [英] Using the pkg-config macro PKG_CHECK_MODULES failing

查看:72
本文介绍了使用 pkg-config 宏 PKG_CHECK_MODULES 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这是一个相当简单的问题.我有一个非常简单的 configure.ac 文件,我用它来学习 autoconf &pkg-config 一起工作.confgure.ac 文件如下所示:

I'm sure this is a fairly simple problem. I have a very simple configure.ac file which I am using to just learn how autoconf & pkg-config work together. The confgure.ac file looks like:

AC_PREREQ(2.61)
AC_INIT(autoconf_test, 1.0, nowhere@dev.null)

PKG_CHECK_MODULES(libusbmuxd, libusbmuxd >= 0.1.4)

然后我可以从命令行执行 autoconf,它会生成一个配置脚本.但是,当我运行配置脚本时,出现以下错误:

I can then execute autoconf from the command line and it does produce a configure script. However, when I run the configure script, I get the following error:

./configure: line 1618: syntax error near unexpected token `libusbmuxd,'
./configure: line 1618: `PKG_CHECK_MODULES(libusbmuxd, libusbmuxd >= 0.1.4)'

如果我从命令行使用 pkg-config 程序检查是否可以找到该库,则成功.

If I use the pkg-config program from the command line to check to see whether it can find this library, it succeeds.

/usr/lib/pkgconfig $pkg-config --libs --cflags --modversion libusbmuxd

1.0.7
-I/usr/local/Cellar/usbmuxd/1.0.7/include  -L/usr/local/Cellar/usbmuxd/1.0.7/lib -lusbmuxd  

所以,很明显,由于某种原因无法找到 PGK_CHECK_MODULE 宏,我不知道为什么.

So, it seems clear that for some reason the PGK_CHECK_MODULE macro cannot be located and I am not sure why.

这可能不是特定于操作系统的,但我使用的是 Mac OS X 10.6.8.

This probably isn't OS specific, but I am using Mac OS X 10.6.8.

推荐答案

在引导(即运行 autoreconf)时,aclocal 无法找到 pkg.m4.这是因为 pkg-config 要么没有安装,要么已经安装在 aclocal 不知道的地方.(即,它安装的前缀与 automake 不同.)要解决此问题,您需要找到 pkg-config 安装 pkg.m4 的位置并将该目录添加到搜索路径.例如,如果 pkg-config 安装了 $HOME/share/aclocal/pkg.m4,你应该运行 autoreconf -I$HOME/share/aclocal

When you are bootstrapping (ie, running autoreconf), aclocal is unable to find pkg.m4. This is because pkg-config was either not installed or has been installed somewhere that aclocal does not know about. (ie, it was installed with a different prefix than automake.) To solve this, you need to find where pkg-config installed pkg.m4 and add that directory to the search path. eg, if pkg-config installed $HOME/share/aclocal/pkg.m4, you should run autoreconf -I$HOME/share/aclocal

实际上有一个很大的学派认为将 pkg-config 与 autotools 一起使用的最佳方法是不使用它.如果您查看 autoconf 邮件列表存档,您将看到这个争论不休的广告.请注意,许多人确实建议完全避免使用它.

There is actually a large school of thought that says that the best way to use pkg-config with the autotools is to not use it. If you look through the autoconf mailing list archive, you will see this debated ad-nauseum. Be aware that many people do recommend avoiding it completely.

这篇关于使用 pkg-config 宏 PKG_CHECK_MODULES 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆