public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* libm.a
@ 2004-12-22 11:27 Ooijen, H.P.G. van
  0 siblings, 0 replies; 2+ messages in thread
From: Ooijen, H.P.G. van @ 2004-12-22 11:27 UTC (permalink / raw)
  To: gcc-help

Dear mrs./mr.

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.


Kind regards,

Dr. H. van Ooijen
Technische Universiteit Eindhoven 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: libm.a
@ 2004-12-22 13:12 Bud Davis
  0 siblings, 0 replies; 2+ messages in thread
From: Bud Davis @ 2004-12-22 13:12 UTC (permalink / raw)
  To: gcc-help; +Cc: h.p.g.ooijen


> 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 <stdio.h>
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



 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-22 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-22 11:27 libm.a Ooijen, H.P.G. van
2004-12-22 13:12 libm.a Bud Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).