[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: cos() in math.h ?

On 03-Aug-2000 Christophe TROESTLER wrote:
> Hi all,
> According to the man page, if I want to use `cos' in a program, I
> simply need to include `math.h'.  However, when I compile, I got the
> error:
>       /tmp/cc9WOsLC.o(.text+0x16): undefined reference to `cos'
>       collect2: ld returned 1 exit status
> I got the necessary packages to compile (e.g., libc6-dev).  Any idea
> what is the cause ?

when you use something from math.h you have to link with libmath, using -lm on
the command line:

gcc foo.c -lm -o foo

Reply to: