When we use "math.h" functions in our C program we often get error like "undefined reference to `sqrt' " while compiling the program using GCC.
We can get rid of the error by explicitly linking the math library while building the executable.
To do the same in Unix/Linux just add 'lm' at the the end of the command.
(Note: The '-lm' should be at the end)
For ex :
We can get rid of the error by explicitly linking the math library while building the executable.
To do the same in Unix/Linux just add 'lm' at the the end of the command.
(Note: The '-lm' should be at the end)
For ex :
gcc test.c -o test -lm
No comments:
Post a Comment