math.h prob

Dave Brennan 9147261b@clinmed.gla.ac.uk
Wed Nov 3 08:21:00 GMT 1999


Hi,

I am fairly new to C programming, especially to using gcc, so I am sorry
if my question is a bit simple!

I am using gcc 2.8.1 on a Sun workstation (solaris 2.7).

I am having problems using maths functions. e.g if I have the program

#include <stdio.h>
#include <math.h>

main()
{

double x;

scanf("%lf",&x);

printf("x = %lf",sqrt(x));


}

and try to compile it using,

gcc -o test mattest.c

I get the following error:

Undefined                       first referenced
 symbol                             in file
sqrt                                /var/tmp/cc9Eay_r1.o
ld: fatal: Symbol referencing errors. No output written to test

Does anyone know why this is happening?

Thanks for the help.


Dave Brennan



More information about the Gcc-help mailing list