I am a beginner for C. I tried to make a simple program to use sqrt function to calculate square root. But I got some trouble.
Here is the simple program calculate.c:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
main()
{ int i= 10;
double j;
j= sqrt (i);
}
Then I did the following:
cc calculate.c
And I got the error message:
/tmp/cc5EiCqg.o(.text+0x2a8d): In function 'main':
:undefined reference to 'sqrt'
collect2: ld returned 1 exit status
The system I used is Linux, and I don't know why this happens.
anybody can help me?


Sign In
Create Account

Guest_fxg03_*
Back to top










