Hi, I'm so new with c language, therefore this may be a fool one. Here's my code: #include <stdio.h> #include <math.h> main() { double x; x = 64.0; printf("kok : %f.\n", sqrt(x)); return 0; } In function `main': : undefined reference to `sqrt' collect2: ld returned 1 exit status Seems it can't find it in math.h; true? A grep showed me it's in tgmath.h instead.But including tgmath.h also didn't change anything. Thanks in advance..
Am Mittwoch, 29. Oktober 2003 21:24 schrieb oguz eren:
I'm so new with c language, therefore this may be a fool one.
Here's my code:
#include <stdio.h> #include <math.h>
main() { double x; x = 64.0; printf("kok : %f.\n", sqrt(x)); return 0; }
In function `main': : undefined reference to `sqrt'
collect2: ld returned 1 exit status
Seems it can't find it in math.h; true? A grep showed me it's in tgmath.h instead.But including tgmath.h also didn't change anything.
No, you have to link it with libm. $ gcc -lm -o program program.c -- Andreas
participants (2)
-
Andreas Winkelmann
-
oguz eren