提升和自动提供

pet*_*ohn 11 linux autoconf boost

我正在制作一个使用Autoconf的项目.我有以下内容configure.ac:

AC_CHECK_HEADERS([boost/foreach.hpp], [],
    [AC_MSG_ERROR(You need the Boost libraries.)])
Run Code Online (Sandbox Code Playgroud)

当我运行时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.
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为我有Boost.如果我删除了检查,代码编译,我安装了Boost:

$ find /usr/include -name foreach.hpp
/usr/include/boost/foreach.hpp
/usr/include/boost/test/utils/foreach.hpp
Run Code Online (Sandbox Code Playgroud)

请注意,我对SDL做了完全相同的工作.

AC_CHECK_HEADERS([SDL/SDL.h], [],
    [AC_MSG_ERROR(You need the SDL development library.)])
Run Code Online (Sandbox Code Playgroud)

...

checking SDL/SDL.h usability... yes
checking SDL/SDL.h presence... yes
checking for SDL/SDL.h... yes
Run Code Online (Sandbox Code Playgroud)

aca*_*bot 16

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++])
Run Code Online (Sandbox Code Playgroud)


Rhy*_*ich 9

您可能对github.com/tsuna/boost.m4感兴趣,它是一组用于检查Boost标头和库的Autoconf宏,以及最小的Boost版本.


lda*_*v1s 8

GNU Autoconf Archive中还有一组Boost autoconf宏.您可能至少需要AX_BOOST_BASE.其他Boost库的其他宏也有.