🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50010

Re: GCC doesn't take math functions

#50010
From: Fergus Henderson
Date: Fri, 26 Nov 1993 15:01
30 lines
1393 bytes
tzusheng@cs.utk.edu (Tzusheng) writes:

>Recently I started using GCC 2.4.5 on Linux. I have a small program 
>as follows:
>#include <stdio.h>
>#include <math.h>
>#include <stdlib.h>
>
>main()
>{
>  float ff, gg;
>
>
>      ff = cos(1.00);
>      gg = sin(1.5);
>}
>
>The messages from compiling:
>$ gcc test.c
>/usr/tmp/cca008811.o: Undefined symbol _cos referenced from text segment
>/usr/tmp/cca008811.o: Undefined symbol _sin referenced from text segment
>
>It seems to me that it doesn't recognize the two math functions.

This is answered in the Linux GCC FAQ List question 33.
You need to specify the `-lm' option to tell gcc to link in the
math libraries.

-- 
Fergus Henderson                     fjh@munta.cs.mu.OZ.AU
Technical Details
Message-ID: <9333102.995@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!yale.edu!spool.mu.edu!sgiblab!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
References: <2d43adINN81o@duncan.cs.utk.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,717acb45b9044233
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-11-26 07:05:06 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!yale.edu!spool.mu.edu!sgiblab!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: GCC doesn't take math functions
Message-ID: <9333102.995@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <2d43adINN81o@duncan.cs.utk.edu>
Date: Fri, 26 Nov 1993 15:01:50 GMT
Lines: 30