From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15570 invoked by alias); 22 Dec 2004 13:12:43 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 15543 invoked from network); 22 Dec 2004 13:12:37 -0000 Received: from unknown (HELO sccrmhc11.comcast.net) (204.127.202.55) by sourceware.org with SMTP; 22 Dec 2004 13:12:37 -0000 Received: from [192.168.1.102] (c-24-0-52-61.client.comcast.net[24.0.52.61]) by comcast.net (sccrmhc11) with SMTP id <2004122213123601100b2qk4e>; Wed, 22 Dec 2004 13:12:36 +0000 Subject: Re: libm.a From: Bud Davis To: gcc-help@gcc.gnu.org Cc: h.p.g.ooijen@tm.tue.nl Content-Type: text/plain Message-Id: <1103721155.1799.15.camel@localhost.localdomain> Mime-Version: 1.0 Date: Wed, 22 Dec 2004 13:12:00 -0000 Content-Transfer-Encoding: 7bit X-SW-Source: 2004-12/txt/msg00207.txt.bz2 > I am trying to compile a program written in C that uses Fortran routines > . However after compilation of the Fortran routines by g77, I get error > messages when I try to compile my program and to link t with the > translated Fortran routines (by using gcc). I get the impression that > thes messages are caused by the fact that I do not have libm.a > (the messages are like : undefined reference to power_dd, s_wsfe etc.). > Nobody here can help me, so maybe you can tell me where to get the > mathematical library libm.a. > > Assuming you are on a linux system, or a close derivative, add the following to your list of libraries during the final link: -lg2c -lm Here is a little example: $ cat t.c #include void x_(int*); int main() { int j; printf("this print is from the C program \n"); j = 123; x_(&j); return 0; } $ cat tf.f subroutine x(i) integer*4 i print*,'this print is from the fortran',i end $ g77 -c tf.f $ gcc t.c tf.o tf.o(.text+0xe): In function `x_': : undefined reference to `s_wsle' tf.o(.text+0x32): In function `x_': : undefined reference to `do_lio' tf.o(.text+0x55): In function `x_': : undefined reference to `do_lio' tf.o(.text+0x5a): In function `x_': : undefined reference to `e_wsle' collect2: ld returned 1 exit status $ gcc t.c tf.o -lg2c $ ./a.out this print is from the C program this print is from the fortran 123 HTH, bud davis