Linking c++ and fortran
Peter_Hahne
Peter_Hahne@t-online.de
Tue Mar 7 09:14:00 GMT 2000
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
More information about the Gcc-help
mailing list