undefined reference to 'sqrt'
The linker cannot find a standard library function that is used in the code.
-lm)#include <math.h>
#include <stdio.h>
int main() {
double result = sqrt(2.0);
printf("Square root of 2 is %f\n", result);
return 0;
}
// Compiled with: gcc -o program main.c
// Missing -lm flagLink the appropriate library when compiling.
// Compile with: // gcc -o program main.c -lm
-lm