This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Error: undefined reference to cos
- From: Eric Christopher <echristo at redhat dot com>
- To: Jnanesh <jnanesh at vsnl dot net>
- Cc: gcc at gnu dot org
- Date: 04 Apr 2003 17:09:04 -0800
- Subject: Re: Error: undefined reference to cos
- Organization:
- References: <3E8E2AC8.5050207@vsnl.net>
Use -lm to link in libm when you compile your program.
-eric
On Fri, 2003-04-04 at 17:00, Jnanesh wrote:
> I am using gcc 3.2 on Red Hat Linux 8.0
> When I compiled the C program given below using the command: cc test.c
>
> #include <stdio.h>
> #include <math.h>
> #define pi 3.1415
> int main()
> {
> double a;
> a=sin(pi/2);
> printf("a = %lf",a);
> return(0);
> }
>
> It gives errors as given below
>
> In function `main':
> /tmp/ccBFnFNj.o(.text+0x1e): undefined reference to `sin'
> collect2: ld returned 1 exit status
>
> Please help me out to see through this problem
--
Eric Christopher <echristo at redhat dot com>