sqrt does not work?

Tried the example on the reference, see below. Getting error message as below. Any idea why?


Undefined first referenced
symbol in file
sqrt /var/tmp//ccCiXlKb.o
ld: fatal: Symbol referencing errors. No output written to sqr
collect2: ld returned 1 exit status


/* 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;
}

you need to link to the math library
I see the in my directory : math.h -> /usr/include/math.h

Is there anything specifically I have to do to get this seen? Thx
-lm

on the link line
Sorry I do not get this. Probably I am the dummiest in this field. All I need is to compile and run the probram to get sqrt of any value. The link to the math.h exists in my directory. But, I am getting the same compilation errors. I need a clear step by step instructions.
g++ sqrt.cpp -lm -o sqr
thank you, sincerely. That makes my life very easy as there are other math functions that I need to use on my project...
Should this even have been in the Lounge section?
Topic archived. No new replies allowed.