autoconf
[Top][All Lists]
Advanced

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

help with C++/Fortran linking


From: Brian T.N. Gunney
Subject: help with C++/Fortran linking
Date: Wed, 30 May 2007 12:49:53 -0700
User-agent: Mutt/1.5.6i

Hello,

I think this problem is solved, but I can't seem to get it to work.
I'm trying to ink a C++ program with fortran objects, but I get

make[1]: Entering directory `/home/gunney/acbug/li-gcc'
g77  -g -O2 -c -o fortfile.o `test -f '../acb/fortfile.f' || echo 
'../acb/'`../acb/fortfile.f
rm -f libacb.a
ar cru libacb.a fortfile.o
ranlib libacb.a
source='../acb/cprog.C' object='cprog.o' libtool=no \
depfile='.deps/cprog.Po' tmpdepfile='.deps/cprog.TPo' \
depmode=gcc3 /bin/sh ../acb/depcomp \
g++ -DHAVE_CONFIG_H -I. -I../acb -I.     -g -O2 -c -o cprog.o `test -f 
'../acb/cprog.C' || echo '../acb/'`../acb/cprog.C
g++  -g -O2   -o cprog 
-L/nfs/apps/gcc/3.3.6/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.6 
-L/nfs/apps/gcc/3.3.6/bin/../lib/gcc-lib 
-L/usr/apps/gcc/3.3.6/lib/gcc-lib/i686-pc-linux-gnu/3.3.6 
-L/nfs/apps/gcc/3.3.6/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.6/../../.. 
-L/usr/apps/gcc/3.3.6/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/../../.. -lfrtbegin 
-lg2c -lm -lgcc_s cprog.o libacb.a
/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__'
collect2: ld returned 1 exit status

I'm not sure why I get this, as I think I am using AC_F77_WRAPPERS,
AC_F77_MAIN and AC_F77_LIBRARY_LDFLAGS properly.  But, maybe I'm not.

I've searched the info pages and google but can't find what I'm doing
wrong.  I would appreciate some help.  My relevant files follow.

Thanks.

more configure.ac Makefile.am fortfile.f cprog.C
::::::::::::::
configure.ac
::::::::::::::
AC_INIT(Makefile.am)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE( acb, 0.1 )
AM_CONFIG_HEADER(config.h)
AC_PROG_CXX
AC_PROG_F77
AC_PROG_RANLIB
AC_F77_WRAPPERS
AC_F77_MAIN
AC_F77_LIBRARY_LDFLAGS
DISTCHECK_CONFIGURE_FLAGS=$ac_configure_args
AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
AC_OUTPUT([ Makefile ], [ ], [ ])
::::::::::::::
Makefile.am
::::::::::::::
lib_LIBRARIES = libacb.a
libacb_a_SOURCES = fortfile.f

bin_PROGRAMS = cprog
cprog_SOURCES = cprog.C
cprog_LDADD = libacb.a
cprog_LDFLAGS = $(FLIBS)

EXTRA_DIST = preconf
::::::::::::::
fortfile.f
::::::::::::::
      subroutine fortsub(x)
      double precision x
c     write(*,*) "This is the forsub subroutine."
      write(*,*) "forsub subroutine: sqrt(", x, ")=", sqrt(x)
      return
      end
::::::::::::::
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

int F77_MAIN( int argc, char **argv ) {
   double x = 2.0;
   F77_FUNC(fortsub,FORTSUB)(x);
   return 0;
}

--
Brian T.N. Gunney                        | Tel: (925) 422-4115
Center for Applied Scientific Computing  | Fax: (925) 423-6374
Lawrence Livermore National Laboratory   | Lab: (925) 422-1100
Mail Code L-561                          | address@hidden
P.O. Box 808 Livermore, CA 94550-0808    |
7000 East Ave., Livermore, CA 94550-9234 | http://www.llnl.gov/CASC




reply via email to

[Prev in Thread] Current Thread [Next in Thread]