1
votes

I know how to check for functions, libraries and modules in my configure.ac file. But I don't know how to check for the existence of a header-only library.

Assume I want to write a project in C++ and I want to use a header library, e.g. a C++ template. For example, Boost Hash. It's Boost's extension of std::hash.

What is the standard way to check in configure.ac whether Boost Hash is installed? I looked for an answer, but all I found was checking for specific headers or libraries, while what I need is to check for existence of a header library.

Is there a standard way to do it in Autoconf, or I need to manually check for the headers I need, one by one?

I found several M4 macros which test existence of Boost libraries, but this is a solution specific to Boost. What do I do with other header libraries, like the ones I write myself?

1

1 Answers

3
votes

mostly it depends on your needs... but, checking for every single header file is not a good idea (because, in case of boost, can take a loooong time :).

if your software require this library, you may check for most important headers. you even can try to build a sample program, just to check that everything looks OK. for example it may #include smth and just print a version of library (for further checks if you need)... in case of failure you have to issue an error. if this library is optional, you may just issue a warning/info/whatever, and define HAS_BLAH_BLAH in your generated config.h file, then check this define before #include -- but anyway, try to build even simplest example -- it is better than check for presence of all library's headers...