Date: Mon, 24 Mar 1997 09:31:33 -0500 (EST) From: Jason Andresen <jandrese@vt.edu> To: Obi Wan Oblivion <vdk@logrus.mv.com> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Problems with math.h Message-ID: <Pine.BSF.3.95.970324093035.408A-100000@jandrese.async.vt.edu> 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
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?
=)
Ahh, you didn't include the math library. Try:
cc -g -o sqrt sqrt.c -lm
:::::::::::::::::::::::::::. . . . . ..::::::::::::::::::::::::::::
:: Jason Andresen :. . . . . . . . . : Web and FTP server at ::
:: jandrese@vt.edu :.:.:.:.:.:.:.:.:.:: jandrese.async.vt.edu ::
:.........................: Quote of the day :..........................:
Nothing is more admirable than the fortitude with which millionaires
tolerate the disadvantages of their wealth.
-- Nero Wolfe
:::::::::::.:.:.:.:.:.:.:.........................:.:.:.:.:.:.:.:::::::::::
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.970324093035.408A-100000>
