This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Linking c++ and fortran


Hello

I´m trying to call a fortran routine from a c++ routine
using gcc resp. g77/g++ , but dont get it to work.
Can somebody tell me how to do it?

Best regards, Peter


I tried
	g77 -o main main.cpp sub1.f -lstdc++  

and get the linker error message
 
	/tmp/ccK77Fls.o: In function `main':
	/tmp/ccK77Fls.o(.text+0x26): undefined reference to `sub1_(void)'
	collect2: ld returned 1 exit status

I am using

g77 version egcs-2.91.66 19990314 (egcs-1.1.2 release) (from FSF-g77 version 
0.5.24-19981002)

The sourcefiles are main.cpp

#include "iostream.h"
int sub1_();
main()
{
	cout << "main" << "\n";
	sub1_();
}

and sub1.f

      integer function sub1()
      sub1=0
      write (6,*) 'sub1'
      return
      end

----------------------------------------------------------------------
Dr.Peter Hahne, Zum Pitschgrund 7a, 64747 Breuberg Rai-Breitenbach,
Tel. +49 6165 912424, Fax +49 6165 912425, Mobile +49 171 5178749


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]