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="somedi rectory" .
I am appending the path of "somedirect ory" 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(spe c_include, [ --with-spec-include=DIR SPEC include
directory], with_spec_inclu de=$withval)
if test -d "$with_spec_inc lude"; then
CPPFLAGS="$CPPF LAGS -I$with_spec_inc lude"
else
with_spec_inclu de=
fi
AC_TRY_COMPILE([
#include "OptionalHeader .hh"
], , AC_MSG_RESULT(y es),
[AC_MSG_RESULT(n o)
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(Optional Header.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_prov ided_by_user"
Thanks in Advance
Amit Gangrade
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="somedi rectory" .
I am appending the path of "somedirect ory" 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(spe c_include, [ --with-spec-include=DIR SPEC include
directory], with_spec_inclu de=$withval)
if test -d "$with_spec_inc lude"; then
CPPFLAGS="$CPPF LAGS -I$with_spec_inc lude"
else
with_spec_inclu de=
fi
AC_TRY_COMPILE([
#include "OptionalHeader .hh"
], , AC_MSG_RESULT(y es),
[AC_MSG_RESULT(n o)
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(Optional Header.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_prov ided_by_user"
Thanks in Advance
Amit Gangrade
Comment