在一些环境中运行autoreconf或者autogen.sh时有时候会出现如下问题:
configure.ac:163: error: possibly undefined macro: AC_ENABLE_SHARED If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. configure.ac:164: error: possibly undefined macro: AC_PROG_LIBTOOL autoreconf: /usr/bin/autoconf failed with exit status: 1
出现这种类似问题一个原因是相关的库没有安装,或者是库的位置对不上,可通过如下方法逐步排查:
1 先安装相关软件包
sudo apt install automake libtool m4 autoconf
2 检查安装目录
grep "AC_ENABLE_SHARED" --color -rn /usr/
通过上述命令查看AC_ENABLE_SHARED这些宏在哪个目录下文件定义,例如我的环境是在/usr/share/aclocal目录下:
-bash-4.2$ grep "AC_ENABLE_SHARED" --color -rn /usr/share/* /usr/share/aclocal/ltoptions.m4:195:AC_DEFUN([AC_ENABLE_SHARED], /usr/share/aclocal/ltoptions.m4:203:AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
3 指定lib目录解决无法找到宏的问题
autoreconf --include=/usr/share/aclocal/