我正在制作一个使用Autoconf的项目。我在configure.ac
中有以下内容:
AC_CHECK_HEADERS([boost/foreach.hpp], [],
[AC_MSG_ERROR(You need the Boost libraries.)])
当我运行configure
时,它说它找不到这个头文件:
checking boost/foreach.hpp usability... no
checking boost/foreach.hpp presence... no
checking for boost/foreach.hpp... no
configure: error: You need the Boost libraries.
这很奇怪,因为我有Boost。如果我删除了检查,代码编译,我安装了Boost:
$ find /usr/include -name foreach.hpp
/usr/include/boost/foreach.hpp
/usr/include/boost/test/utils/foreach.hpp
请注意,我对SDL做了完全相同的工作。
AC_CHECK_HEADERS([SDL/SDL.h], [],
[AC_MSG_ERROR(You need the SDL development library.)])
...
checking SDL/SDL.h usability... yes
checking SDL/SDL.h presence... yes
checking for SDL/SDL.h... yes
AC_CHECK_HEADERS实际上进行了编译检查,而不是存在检查。因此,您必须为编译测试设置C ++支持,以便编译boost头文件(默认为C,docs here):
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([boost/foreach.hpp], [],
[AC_MSG_ERROR(You need the Boost libraries.)])
AC_LANG_POP([C++])
您可能对github.com/tsuna/boost.m4感兴趣,它是一组用于检查Boost标头和库的Autoconf宏,以及最小的Boost版本。
在GNU Autoconf Archive还有一系列Boost autoconf宏。你可能至少需要AX_BOOST_BASE。其他Boost库的其他宏也有。