Re: How can I check if C++ and Fortran compiler works ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ralf Wildenhues wrote:
* Dr. David Kirkby wrote on Sun, Feb 21, 2010 at 11:53:05PM CET:
There is no actual test that the C++ compiler works. How can I add
one?

You could simply test whether it can link a trivial program.  Call
the macro below after AC_PROG_CXX.

I intend to submit this macro, suitably rewritten and factored, as
Autoconf addition, since it's come up twice within two days now.

Cheers,
Ralf

# rw_PROG_CXX_WORKS
# Check whether the C++ compiler works.
AC_DEFUN([rw_PROG_CXX_WORKS],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_CACHE_CHECK([whether the C++ compiler works],
               [rw_cv_prog_cxx_works],
               [AC_LANG_PUSH([C++])
                AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
                               [rw_cv_prog_cxx_works=yes],
                               [rw_cv_prog_cxx_works=no])
                AC_LANG_POP([C++])])
])

Thank you. I'll add that macro and something to configure.ac to ensure the C++ compiler is at least semi sensible. I'm really not sure what was causing the error message "complex.h: present but cannot be compiled" but there is at least some suspicion the person who got this error did not have a working C++ compiler, so it seems sensible to check that.

Could you do likewise for Fortran?

I've done this, which makes the assumption that if the compiler will not accept freeform source code, then it won't be suitable, but it is a bit of a hack.

   AC_PROG_FC()
   AC_FC_FREEFORM([
   AC_MSG_NOTICE([Your Fortran compiler accepts free-format source code])
   AC_MSG_NOTICE([which older F77 compilers do not. This does not 100%])
   AC_MSG_NOTICE([guarantee your compiler is suitable for building SAGE])
   AC_MSG_NOTICE([but it probably is.])
   ],
   [
   AC_MSG_NOTICE([Your Fortran compiler does not accept free-format source code])
   AC_MSG_NOTICE([which means the compiler is either seriously broken, or])
   AC_MSG_NOTICE([is too old to build Sage.])

Dave


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux