Problem with autoconf

A

Amit Gangrade

I am trying to make a configure script for a c++ library . The library can
be compiled with some optional header files,depending on the users
decision . So basically I need to check for the headers in the path that the
user gives in the --with-somelibrary-include="somedirectory" .

I am appending the path of "somedirectory" to CPPFLAGS and then using
AC_TRY_COMPILE macro , I am trying to compile a program
which includes those optional header files .
I am putting the part of code from configure.in file

# part of code from configure.in

AC_ARG_WITH(spec_include, [ --with-spec-include=DIR SPEC include
directory], with_spec_include=$withval)

if test -d "$with_spec_include"; then
CPPFLAGS="$CPPFLAGS -I$with_spec_include"
else
with_spec_include=
fi


AC_TRY_COMPILE([
#include "OptionalHeader.hh"
], , AC_MSG_RESULT(yes),
[AC_MSG_RESULT(no)
AC_MSG_ERROR([Optional header missing in the given path])])

# configure.in ends

The problem is that OptionalHeader.hh is a c++ header file . When i checked
the config.log file ,i find that
configure is using gcc to compile conftest.c file which includes c++
header(OptionalHeader.hh) . To be more clear I am putting
the line from config.log after which the configure fails.

gcc -c -g -O2 -I"somedirectory" conftest.c

When I compiled the program using g++ or by renaming conftest.c to
conftest.cpp ,it is compilng . So i guess the error is because that
configure
while testing for headers in AC_TRY_COMPILE macro used gcc by default.
Is there any way to use g++ to compile the code in AC_TRY_COMPILE instead of
gcc.
or is there some other way to check for header files in the path provided by
user .(not using AC_CHECK_HEADER because i want to look for header only in
the path that the user provides while running configure)
Ex. configure --check-in-path="path_provided_by_user"

Thanks in Advance
Amit Gangrade
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top