Originally Posted by jpollard
It should be in the math library. Add "-lm" to the command used to compile it.
I agree. The rest of what I have to say only explains that answer. It doesn't replace that answer.
Originally Posted by islam_assi
although I wrote (#include "math.h") in the main
Both the declaration and the definition of the function are required.
math.h provides the declaration of the function at compile time in a way that requires the definition to be provided at link time.
The -lm provides access to the definition at link time.
We assume a single gcc command was used to both compile and link, so the -lm could be added to that command. If separate commands were used for compile and link, the -lm belongs on the link command.