未找到第 3 方 aclocal 目录中的 M4 宏

Posted

技术标签:

【中文标题】未找到第 3 方 aclocal 目录中的 M4 宏【英文标题】:M4 macros in the 3rd-party aclocal directory are not found 【发布时间】:2016-06-25 18:56:44 【问题描述】:

我在没有 root 访问权限的系统上本地安装了较新版本的 automake (1.15)。本地目录的bin文件夹是我PATH的第一个目录。

我还在本地安装了gtk+-2.0,现在我想构建和安装一个需要gtk 作为依赖项的应用程序,即我想要的应用程序的configure.ac 脚本包含:

PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.0])

为确保找到 m4 宏,我将 gtk_install_dir/share/aclocal 中的 .m4 文件复制到 aclocal --print 指定的位置 (automake_install_dir/share/aclocal/)。

我也设置了PKG_CONFIG_PATH=gtk_install_dir/lib/pkgconfig

但是,当我运行时:

$ libtoolize
$ aclocal
$ autoconf
$ automake
$ ./configure

我收到一条错误消息:

./configure: line 13106: syntax error near unexpected token `GTK,'
./configure: line 13106: `PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.0)'

运行aclocal --verbose我可以清楚的看到没有提到gtk,所以显然没有找到gtk+宏。

我以前没有使用过这些构建工具,是我遗漏了什么吗?我似乎无法让配置脚本识别 gtk 已安装!

非常感谢任何建议,谢谢。

编辑:我可以确认pkg-config 知道我的 gtk 安装在哪里:

$ pkg-config --print-variables gtk+-2.0
exec_prefix
gtk_binary_version
...

也由pkg-config --debug gtk+-2.0 确认。如果pkg-config 对包了如指掌,为什么autotools 不知道?

【问题讨论】:

【参考方案1】:

您需要确保已安装 pkg-config-devel 或类似名称的软件包。没有它,aclocal 无法找到./configure 调用pkg-config 所需的 PKG_CHECK_MODULES

您尝试构建的软件可能m4/ 等子目录中有一个 pkg.m4 文件,但如果未正确配置它可能实际上不会注意到,请尝试使用autoreconf -fis -I m4如果有这样的目录。

【讨论】:

有人可以点赞这条评论吗?这是唯一解决我问题的方法!!!通过谷歌很难找到

以上是关于未找到第 3 方 aclocal 目录中的 M4 宏的主要内容,如果未能解决你的问题,请参考以下文章

aclocal-1.16:未找到命令

pcre-8.36/missing:行81: aclocal-1.14: 未找到命令

C++学习(三五九)GNU构建系统Autotools(autoconf automake libtool autoscan autoheader aclocal automake m4)

如何在makefile中指定头文件目录

Linux下使用automakeautoconf生成configure文件

Linux下使用automakeautoconf生成configure文件