delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/03/11/12:02:14

To: Mike Piff <M DOT Piff AT sheffield DOT ac DOT uk>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Simple problems
Date: Fri, 11 Mar 94 11:16:40 -0500
From: Mike Collison <collison AT sw DOT stratus DOT com>

> Why will the following not work? (My first use of maths with C and my second
> ever use of C!)  The linker says there is an unresolved reference to sqrt??


> #include <math.h>

> int x;

> main(){
>  x=sqrt(2.0);
> }

> (OK, I know x should be float!)

Add a '-lm' on the command line. The linker does not search
the math library by default.

Mike

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019