User forums > Help
Why windows don't show this error but i get this?
Alif:
I'm sorry if I make any mistake in writting. I've gone to to the rules as you asked.
By the way,
I came to know after searching the net for a while; windows don't show an error /*undefined refferences*/ while using sqrt() or pow() functions. But in linux it shows.
so i just want to know what is the speciality of windows then?
Then I'll request you a thing that Is it possible to link "m" by default in the compiler settings? so that new linux user don't get scared or frustated with linux. They will think linux always causes problems. Please say something.
oBFusCATed:
Linking libm is not required to do manually if you're using the correct linker (gcc or g++).
So you'll have to post more details like full build log, screenshot of the toolchain executables and os/compiler/codeblocks version numbers.
Alif:
--- Quote from: oBFusCATed on July 28, 2020, 09:47:21 pm ---Linking libm is not required to do manually if you're using the correct linker (gcc or g++).
So you'll have to post more details like full build log, screenshot of the toolchain executables and os/compiler/codeblocks version numbers.
--- End quote ---
os Manjaro Linux; Build ID: rolling
Gnome version:3.36.4
codeblocks version: 20.03-1
compiler: GNU GCC compiler
for this code:
--- Code: ---#include <math.h>
#include <stdio.h>
int main()
{
int n=9;
n= sqrt(n);
printf("%d",n);
return 0;
}
--- End code ---
error is
--- Code: ----------------- 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))
--- End code ---
some people are saying that windows dosen't show this error(?)
Miguel Gimenez:
MinGW does not use a math library, see for example:
https://stackoverflow.com/questions/48134247/why-i-dont-need-the-flag-lm-in-mingw-but-in-linux-i-need-that-explicitly
oBFusCATed:
This is odd, compiling and linking with a single command works without -lm, but a two step compilation requires -lm. :shrug:
Navigation
[0] Message Index
[#] Next page
Go to full version