c - sqrt() function link error -


the following code throwing undefined symbol error on linux.

$ cat rms.c /* sqrt example */ #include <stdio.h> #include <math.h>  int main () {   double param, result;   param = 1024.0;   result = sqrt (param);   printf ("sqrt(%lf) = %lf\n", param, result );   return 0; }   $ gcc rms.c /tmp/ccawecfp.o(.text+0x24): in function `main': : undefined reference `sqrt' collect2: ld returned 1 exit status 

if replace argument sqrt() (double)16 program compiling , executing. why throwing error in first case.

this linker error.

the linker missing implementation of sqrt(). resides in library libm.

tell gcc add applying option -lm.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -