This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Linking c++ and fortran
- To: gcc-help at gcc dot gnu dot org
- Subject: Linking c++ and fortran
- From: Peter_Hahne at t-online dot de (Peter_Hahne)
- Date: Tue, 7 Mar 2000 18:14:23 +0100
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