On Wed, May 30, 2007 at 12:49:53PM -0700, Brian T.N. Gunney wrote: > I'm trying to ink a C++ program with fortran objects, but I get > /nfs/apps/gcc/3.3.6/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.6/../../../libfrtbegin.a(frtbegin.o)(.text+0x32): In function `main': > ../../../../gcc-3.3.6/libf2c/libF77/main.c:28: undefined reference to `MAIN__' You must mark an F77_MAIN function `extern "C"' when you define it in a C++ compilation unit. > cprog.C > :::::::::::::: > #include "config.h" > extern "C" { > void F77_FUNC(fortsub,FORTSUB)( double &x ); > } > > #ifdef F77_DUMMY_MAIN > # ifdef __cplusplus > extern "C" > # endif > int F77_DUMMY_MAIN() { return 1; } > #endif Use exactly one of F77_DUMMY_MAIN or F77_MAIN in a given executable. F77_MAIN is correct for this application; delete the above. > int F77_MAIN( int argc, char **argv ) { Write `extern "C" F77_MAIN( int argc, char **argv ) {' instead. The manual was not explicit on thise point, so I installed the following patch to (hopefully) clarify things. 2007-06-04 Noah Misch <noah@xxxxxxxxxxxxxx> * doc/autoconf.texi (AC_F77_MAIN): Give a specific usage example that works with both C and C++. diff -Nurp -X dontdiff ac-clean/doc/autoconf.texi ac-fortcpp/doc/autoconf.texi --- ac-clean/doc/autoconf.texi 2007-06-04 08:11:56.000000000 -0400 +++ ac-fortcpp/doc/autoconf.texi 2007-06-04 18:39:00.000000000 -0400 @@ -7094,8 +7094,16 @@ alternate main function name is found, @ simply defined to @code{main}.) Thus, when calling Fortran routines from C that perform things like I/O, -one should use this macro and name the "main" function -@code{F77_MAIN} or @code{FC_MAIN} instead of @code{main}. +one should use this macro and declare the "main" function like so: + +@example +#ifdef __cplusplus + extern "C" +#endif +int F77_MAIN(int argc, char *argv[]); +@end example + +(Again, replace @code{F77} with @code{FC} for Fortran instead of Fortran 77.) @end defmac @defmac AC_F77_WRAPPERS _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf