简体   繁体   English

检查Autotools中的外部包装

[英]Check external package in Autotools

I would like to check the presence of the google sparsehash package in my C++ program with the Autotools. 我想使用Autotools在我的C ++程序中检查google sparsehash软件包的存在。

Here is a minimal configure.ac : 这是最小的configure.ac

AC_PREREQ([2.69])
AC_INIT([myprog], [1.0], [adress@email.com])
AC_CONFIG_SRCDIR([main.cpp])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])

AC_PROG_CXX
AC_PROG_CC
AC_CHECK_HEADERS([google/sparse_hash_map])

AC_CONFIG_FILES(Makefile)
AC_OUTPUT

I run autoreconf -vfi , then ./configure , and I get: 我运行autoreconf -vfi ,然后运行./configure ,我得到:

checking google/sparse_hash_map usability... no
checking google/sparse_hash_map presence... no
checking for google/sparse_hash_map... no

However, I can check the presence of /usr/include/google/sparse_hash_map , a C++ file, which is a thin wrapper around /usr/include/google/sparsehash/sparsehashtable.h . 但是,我可以检查/usr/include/google/sparse_hash_map (一个C ++文件)的存在,该文件是/usr/include/google/sparsehash/sparsehashtable.h的薄包装。 Moreover, the tiny code: 此外,微小的代码:

#include <google/sparse_hash_map>
int main() {return 1;}

compiles and executes fine using g++ test.cpp . 使用g++ test.cpp编译并执行良好。

Any suggestion for a newbie? 对新手有什么建议吗?

The AC_CHECK_HEADER macro is using the C compiler by default. 默认情况下, AC_CHECK_HEADER宏正在使用C编译器。 You can change the current language using: AC_LANG([C++]) or: AC_LANG_PUSH([C++]) / AC_LANG_POP - as described in the (single-page) manual . 您可以使用以下语言更改当前语言: AC_LANG([C++])或: AC_LANG_PUSH([C++]) / AC_LANG_POP如(单页) 手册中所述 eg, 例如,

...
AC_LANG([C++])
AC_CHECK_HEADERS([google/sparse_hash_map])
# still in C++ 'mode'

or: 要么:

...
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([google/sparse_hash_map])
AC_LANG_POP([C++])
# restored previous language 'mode'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM