You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更新Linux后autotools报宏过时警告 程序找不到自编译依赖库

问题描述

各位好:
我近期更新了一台Linux主机,尝试重新运行项目所需的构建工具时,得到如下运行输出:

gor@IgorReinCloud ~/dbhandler $ aclocal
igor@IgorReinCloud ~/dbhandler $ autoconf
configure.ac:52: warning: The macro `GLIB_GNU_GETTEXT' is obsolete.
configure.ac:52: You should run autoupdate.
aclocal.m4:388: GLIB_GNU_GETTEXT is expanded from...
aclocal.m4:488: AM_GLIB_GNU_GETTEXT is expanded from...
configure.ac:52: the top level
configure.ac:52: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:52: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
aclocal.m4:73: GLIB_LC_MESSAGES is expanded from...
aclocal.m4:388: GLIB_GNU_GETTEXT is expanded from...
aclocal.m4:488: AM_GLIB_GNU_GETTEXT is expanded from...
configure.ac:52: the top level
configure.ac:52: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:52: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/headers.m4:89: _AC_CHECK_HEADER_COMPILE is expanded from...
./lib/autoconf/headers.m4:56: AC_CHECK_HEADER is expanded from...
aclocal.m4:172: GLIB_WITH_NLS is expanded from...
aclocal.m4:388: GLIB_GNU_GETTEXT is expanded from...
aclocal.m4:488: AM_GLIB_GNU_GETTEXT is expanded from...
configure.ac:52: the top level
configure.ac:52: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:52: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/headers.m4:89: _AC_CHECK_HEADER_COMPILE is expanded from...
./lib/autoconf/headers.m4:56: AC_CHECK_HEADER is expanded from...
aclocal.m4:172: GLIB_WITH_NLS is expanded from...
aclocal.m4:388: GLIB_GNU_GETTEXT is expanded from...
aclocal.m4:488: AM_GLIB_GNU_GETTEXT is expanded from...
configure.ac:52: the top level
configure.ac:52: warning: The macro `AC_OUTPUT_COMMANDS' is obsolete.
configure.ac:52: You should run autoupdate.
./lib/autoconf/status.m4:1025: AC_OUTPUT_COMMANDS is expanded from...
aclocal.m4:172: GLIB_WITH_NLS is expanded from...
aclocal.m4:388: GLIB_GNU_GETTEXT is expanded from...
aclocal.m4:488: AM_GLIB_GNU_GETTEXT is expanded from...
configure.ac:52: the top level
configure.ac:61: warning: AC_OUTPUT should be used without arguments.
configure.ac:61: You should run autoupdate.
igor@IgorReinCloud ~/dbhandler $ 

我是参考公开的autotools构建流程文档操作的。
目前遇到两个问题:

  • 执行aclocal、autoconf时出现大量过时宏警告
  • 忽略警告继续执行构建流程,项目可以正常编译完成,但运行程序时,系统无法找到自行编译的程序依赖库。

需要解决的诉求:

  • 修复上述autotools相关警告
  • 给出可行方案让程序可以正常加载依赖库运行

解决方案

一、修复autotools过时宏警告

这些警告的核心原因是项目的configure.ac使用了新版本autotools已经废弃的旧宏,按以下步骤操作即可修复:

  1. 先清理项目里旧的autotools生成缓存文件
make maintainer-clean
rm -rf aclocal.m4 autom4te.cache configure
  1. 执行autoupdate自动替换过时宏
    autoupdate是autotools自带的工具,会自动扫描configure.ac里的废弃宏,替换为当前版本支持的新语法:
autoupdate
  1. 针对GLIB相关的过时宏手动修正
    GLIB_GNU_GETTEXT、AM_GLIB_GNU_GETTEXT是老版本glib提供的gettext宏,新版本已经不再推荐使用,打开configure.ac找到第52行附近的AM_GLIB_GNU_GETTEXT,直接替换为标准gettext宏:
AM_GNU_GETTEXT_VERSION([0.19.8]) # 填你系统安装的gettext最低兼容版本
AM_GNU_GETTEXT([external])

同时检查configure.ac第61行的AC_OUTPUT,删掉括号里的所有参数,新版本autoconf要求AC_OUTPUT不带任何参数。
4. 重新生成构建文件

aclocal
autoconf
autoheader
automake --add-missing

执行完上述步骤后,再运行autoconf就不会再出现过时宏警告了。

二、修复运行时找不到自定义依赖库的问题

这个问题和上面的宏警告没有直接关联,是Linux动态链接器的默认搜索路径没有包含你自定义编译的依赖库路径导致的,选以下任意一种方案即可:

  1. 编译时指定rpath,把依赖库搜索路径写进二进制文件
    执行configure的时候加上LDFLAGS参数,把你的自定义库存放路径传入:
./configure LDFLAGS="-Wl,-rpath=/path/to/your/custom/lib/directory"

之后重新make编译,生成的二进制会自带依赖库搜索路径,运行时不需要额外配置环境变量就能找到库。
2. 临时配置运行时库路径
如果不想重新编译,运行程序前先设置LD_LIBRARY_PATH环境变量,指向自定义库的存放目录:

export LD_LIBRARY_PATH=/path/to/your/custom/lib/directory:$LD_LIBRARY_PATH
./your_program

注意:这种方法只对当前终端会话生效,关闭终端后需要重新设置。
3. 永久配置系统动态链接器搜索路径
把你的自定义库路径写入/etc/ld.so.conf.d/下的配置文件,然后刷新链接器缓存:

echo "/path/to/your/custom/lib/directory" | sudo tee /etc/ld.so.conf.d/custom-libs.conf
sudo ldconfig

配置完成后所有用户运行程序都能自动找到该路径下的依赖库。


内容的提问来源于stack exchange,提问作者Igor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.29 09:24:13