This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Undefined references when using math.h


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]