Linking libm is not required to do manually if you're using the correct linker (gcc or g++).os Manjaro Linux; Build ID: rolling
So you'll have to post more details like full build log, screenshot of the toolchain executables and os/compiler/codeblocks version numbers.
#include <math.h>
#include <stdio.h>
int main()
{
int n=9;
n= sqrt(n);
printf("%d",n);
return 0;
}
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------
gcc -c /home/ali/Documents/codeblocks_codes/error.c -o /home/ali/Documents/codeblocks_codes/error.o
gcc -o /home/ali/Documents/codeblocks_codes/error /home/ali/Documents/codeblocks_codes/error.o
/usr/bin/ld: /home/ali/Documents/codeblocks_codes/error.o: in function `main':
error.c:(.text+0x23): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
This is odd, compiling and linking with a single command works without -lm, but a two step compilation requires -lm. :shrug: