From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter_Hahne@t-online.de (Peter_Hahne) To: gcc-help@gcc.gnu.org Subject: Linking c++ and fortran Date: Tue, 07 Mar 2000 09:14:00 -0000 Message-id: <12SNYt-1cotlIC@fwd00.sul.t-online.de> X-SW-Source: 2000-03/msg00027.html 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter_Hahne@t-online.de (Peter_Hahne) To: gcc-help@gcc.gnu.org Subject: Linking c++ and fortran Date: Sat, 01 Apr 2000 00:00:00 -0000 Message-ID: <12SNYt-1cotlIC@fwd00.sul.t-online.de> X-SW-Source: 2000-q1/msg00337.html Message-ID: <20000401000000.F9_M_h5W0Av7FZi5vD-F2LGvcnJW1ovNpHdLQwO6dbI@z> 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