Article View: gnu.gcc.help
Article #42314Re: Maths functions (math.h) not working
From: Rusty, Paul , Russell
Date: Mon, 11 Dec 1995 00:00
Date: Mon, 11 Dec 1995 00:00
24 lines
1425 bytes
1425 bytes
In message <818684416.3383@tecton2.demon.co.uk> you write: > Hi, > > When compiling I can't get at maths functions in math.h > My programs have all worked so far but now I'm trying to use the > cos function and gcc reports undefined symbol 'cos' when it's linking. > I know math.h is being included because I've used the PI definition. > > Any ideas on how I can sort this out? Hi Lyndon, You need to add "-lm" to your final link line to tell it to link with the maths library, eg: gcc foo.C -o foo -lm math.h contains the declarations for these functions, but the definitions are in libm.so (Most of the other functions in standard headers are in libc.so, which is linked in by default). Hope this helps, Rusty. -- Rusty.Russell@adelaide.maptek.com.au "Engineer? So you drive trains?" Lies, damned lies, and out-of-date documentation. #include <stddisclm.h>
Technical Details
Message-ID:
<199512120454.PAA02791@gauss.adelaide.maptek.com.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<818684416.3383@tecton2.demon.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,fbfe8c7b97617007,start X-Google-Attributes: gid11318c,public From: Rusty.Russell@adelaide.maptek.com.au (Rusty, Paul , Russell) Subject: Re: Maths functions (math.h) not working Date: 1995/12/11 Message-ID: <199512120454.PAA02791@gauss.adelaide.maptek.com.au> X-Deja-AN: 121609984 distribution: gnu sender: daemon@cis.ohio-state.edu references: <818684416.3383@tecton2.demon.co.uk> organization: GNUs Not Usenet newsgroups: gnu.gcc.help