Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Mar 1997 14:04:22 -0800 (PST)
From:      Burton Sampley <bsampley@best.com>
To:        Obi Wan Oblivion <vdk@logrus.mv.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Problems with math.h
Message-ID:  <Pine.SGI.3.95.970324140307.4099B-100000@shellx.best.com>
In-Reply-To: <Pine.BSF.3.91.970324075510.307E-100000@logrus.mv.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Try g++ <filename> -lm.

You need to tell gcc to link the math libraries with the -lm
command/option. 

On Mon, 24 Mar 1997, Obi Wan Oblivion wrote:

> To Whom It May Concern:
> 
> I am running 2.1.5 and cannot seem to get "sqrt" or "sqrtf" to work.  A 
> good example would be:
> 
> #include <stdio.h>
> #include <math.h>
> 
> main() {
> 
>   unsigned long int number,result;
> 
>   number = 64;
> 
>   result = (unsigned long int)sqrt((double)number);
> 
>   printf("The square root of %d is %d\n", number, result);
> 
>   return(0);
> 
> }
> 
> I build this with "cc -g -o" and get an "Undfined symbol _sqrt".  Are 
> these math functions not in the standard library, or am I doing something 
> really bone-headed?  Also, is typecasting appropriate in this case or 
> will lint shut up and let me do the conversion?
> 
> Thanks!
> 
> -Jeff
> 
> 
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SGI.3.95.970324140307.4099B-100000>