提升和自动提供

问题描述 投票:11回答:3

我正在制作一个使用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
linux boost autoconf
3个回答
16
投票

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++])

9
投票

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


8
投票

GNU Autoconf Archive还有一系列Boost autoconf宏。你可能至少需要AX_BOOST_BASE。其他Boost库的其他宏也有。

© www.soinside.com 2019 - 2024. All rights reserved.