Date: Wed, 1 Oct 1997 08:38:54 +0700 (GMT) From: Alexey Yakovlev To: Mike Kretlow cc: djgpp AT delorie DOT com Subject: Re: Calling fortran subrotuines from C In-Reply-To: <343147a1.399544@news.uni-siegen.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Tue, 30 Sep 1997, Mike Kretlow wrote: > I have some f77 subroutines, which I like to call from my c program. > I compiled the file sub.f with g77 under dos and the main c-program > with djgpp 2, but the linker couldn't find the subroutines (I declared > them of course as extern). Normally, g77 (and many other compilers) names its subroutines in lowercase letters appending an underscore to the name. Example: in FORTRAN SUBROUTINE SUB1(A,B,C) DOUBLEPRECISION A INTEGER B CHARACTER*(*) C END It can be called from C like this main() { double a_c; int b_c; char c_c[80]; sub1_( &a_c, &b_c, c_c, 80 ); // The last parameter is the length of the // string c_c } Alexey ================================================================ Alexey Yakovlev, Quantum Chemistry Lab. Boreskov Institute of Catalysis, Russian Academy of Sciences pr. Lavrentieva 5, 630090 Novosibirsk, Russia phone: +7-(3832)-350264, fax: +7-(3832)-355766 or 357687 e-mail: jack AT catalysis DOT nsk DOT su ================================================================