libm.a
Bud Davis
bdavis9659@comcast.net
Wed Dec 22 13:12:00 GMT 2004
> 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
More information about the Gcc-help
mailing list