Boost and Autoconf
Asked Answered
A

3

13

I am making a project that uses Autoconf. I have the following in configure.ac:

AC_CHECK_HEADERS([boost/foreach.hpp], [],
    [AC_MSG_ERROR(You need the Boost libraries.)])

When I run configure, it says it cannot find this header file:

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.

This is strange, because I have Boost. If I remove the check, the code compiles, and I have Boost installed:

$ find /usr/include -name foreach.hpp
/usr/include/boost/foreach.hpp
/usr/include/boost/test/utils/foreach.hpp

Note that I did exactly the same with SDL, and it works.

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
Autograph answered 21/6, 2010 at 19:58 Comment(1)
Check config.log to see exactly why it failed. academicRobot is probably correct that it is trying to compile with a C compiler.Hanus
C
17

AC_CHECK_HEADERS actually does a a compile check, not an existence check. So you have to set C++ support for compilation tests in order for boost headers to compile (default is 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++])
Cannady answered 21/6, 2010 at 20:26 Comment(0)
L
9

You may be interested in github.com/tsuna/boost.m4, which is a drop-in set of Autoconf macros for checking for Boost headers and libraries, as well as the minimum Boost version.

Lighting answered 22/6, 2010 at 6:13 Comment(0)
D
9

There's also a collection of Boost autoconf macros at the GNU Autoconf Archive. You'll probably need at least AX_BOOST_BASE. Other macros for the other Boost libs are there also.

Digestive answered 20/8, 2010 at 0:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.