undefined reference to `sqrt' collect2: ld returned 1 exit status

When we will compile a c program in Linux GCC compiler we may get error message:

undefined reference to `sqrt' collect2: ld returned 1 exit status

Cause of this error is by default math.h library has not included. 

Solution:

Compile the c code in the following way:

[root@localhost ~]# gcc abc.c -lm

Note: Here abc.c is name of any c code file.

No comments: