我正在做一个使用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 ):
AC_LANG_PUSH([C++]) AC_CHECK_HEADERS([boost/foreach.hpp], [], [AC_MSG_ERROR(You need the Boost libraries.)]) AC_LANG_POP([C++])
不是一个真正的答案 – 尝试boost.m4如果你想用autoconf Boost。
在GNU Autoconf Archive上还有一组Boost的autoconf宏。 您可能至少需要AX_BOOST_BASE 。 其他Boost库的其他宏也在那里。