This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
Undefined references when using math.h
- To: glibc-linux at ricardo dot ecn dot wfu dot edu
- Subject: Undefined references when using math.h
- From: Matt Adams <stormkeeper at softhome dot net>
- Date: Thu, 2 Mar 2000 03:00:30 -0500
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
Hi there,
My apologies if this is off-topic. I kept receiving majordomo errors
when I sent it to linux-c-programming.
I've found something rather unsettling when trying to use a
function from math.h
---example code---
#include <stdio.h>
#include <math.h>
main()
{
double x = 1.0;
double ans;
ans = sqrt(x);
printf("\nans is %lf\n", ans);
return 0;
}
---end example code---
When I attempt to run "cc -o foo foo.c" I get this error:
/tmp/cczmmVQB.o: In function `main':
/tmp/cczmmVQB.o(.text+0x409): undefined reference to `sqrt'
collect2: ld returned 1 exit status
which is rather annoying <g> How might this be fixed?
I would appreciate any suggestions or comments.
Thanks -- Matt
BTW, I'm using gcc, egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
Slackware 7.0, i586