![](https://seccdn.libravatar.org/avatar/da56d9d1cf99cb2141fd4f475f64e88d.jpg?s=120&d=mm&r=g)
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..
![](https://seccdn.libravatar.org/avatar/9527e20ec10ee9eb8b28774c9b754862.jpg?s=120&d=mm&r=g)
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