2010-06-21 40 views
10

我正在製作一個使用Autoconf的項目。我在configure.ac如下:Boost和Autoconf

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. 

這是奇怪的,因爲我有推動作用。如果我刪除了檢查,代碼編譯,我已經安裝了提升:

$ 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 
+4

您可能會對http://github.com/tsuna/boost.m4感興趣,這是一組用於檢查Boost標頭和庫以及最低Boost版本的Autoconf宏的嵌入式集合。 – ZoogieZork 2010-06-21 20:37:00

+0

檢查config.log以查看它的失敗原因。 academicRobot可能是正確的,它試圖用C編譯器進行編譯。 – 2010-06-22 04:43:50

+0

boost.m4完美地爲我工作。我能夠在沒有任何問題的情況下(以及在多個操作系統上)針對多個版本的boost進行構建。 – squeegee 2015-01-04 03:02:39

回答

13

AC_CHECK_HEADERS實際上做了一個編譯檢查,不存在確認。所以,你必須設置C++編譯測試支持,以便提振頭編譯(默認爲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++]) 
8

不是一個真正的answer--嘗試boost.m4如果你想使用升壓與autoconf的。