
Mathew Robertson wrote:
To allow the autoconf tools (ie configure) to detect the presence of the various Boost libs and header file versions, would it be possible to add a C-linkage function to each libraries' source file(s). This would allow users to add a configure check which detects if a particular library instance is installed. For example, we add the following code to each library instance:
extern "C" boost_autoconf() {}
This allows autoconf users to add a test to their configure.in script:
AC_CHECK_LIB(boost_regex,boost_autoconf,...,[Boost::Regex library not found])
I don't see why you need a function with C linkage for this to work. The behavior of autoconf depends on the current language specified in configure.ac at the point where you call AC_CHECK_LIB. If that language is C++, you should well be able to test for functions with C++ linkage. See http://www.gnu.org/software/autoconf/manual/autoconf-2.57/html_chapter/autoc...
Yeah - thats what I'm trying to do. Specifically, I'm trying to detect if "libboost_regex..." is installed, so I have the following:
AC_CHECK_LIB(boost_regex-gcc,<somefunc>,,AC_ERROR([Must have the Boost::Regex library installed])
Now the problem is, 'What do I put in for <somefunc>?' All other C++ libraries I have used, specifically contain a C-linkage function to allow configure to detect it.
I am not familiar with the autoconf tool, but is it possible to have something like this: // include_test.cpp #include <boost/regex.hpp> int main() { // simple regex use here return( 0 ); } //--end That way, you'd get a compile error if regex.hpp is not found (Boost is not on the system) or a link error if the library is not available (library hasn't been built or configured). I am not sure how this translates to autoconf: have you had a look to see how GCC checks for stdio.h, etc.? Regards, Reece _________________________________________________________________ Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo

Reece Dunn wrote:
I am not familiar with the autoconf tool, but is it possible to have something like this:
// include_test.cpp #include <boost/regex.hpp>
int main() { // simple regex use here return( 0 ); } //--end
That way, you'd get a compile error if regex.hpp is not found (Boost is not on the system) or a link error if the library is not available (library hasn't been built or configured).
right. This is the kind of code that is automatically generated by autoconf to figure out whether * the header exists and can be used * the library exists and can be used Note that in your above snippet you don't make any calls into the library, so even though if the linker doesn't find the specified library, there are no unresolved symbols left. Using 'AC_CHECK_LIB' will generate code that tests for a specific function to see whether it can link with it. However, as opposed to what the original poster said, this function doesn't have to have C linkage (see the reference I provided in my earlier mail). Regards, Stefan
participants (2)
-
Reece Dunn
-
Stefan Seefeld