comp.lang.c FAQ list
·
Question 14.3

Q:
I'm trying to do some simple
trig,
and I am #including <math.h>,
but
the linker keeps
complaining
that functions like sin
and cos
are undefined.

A:
Make sure you're actually linking with the math library.
For instance,
due to a longstanding bug in Unix and Linux systems,
you usually need to use an explicit -lm
flag,
at the
end
of the command line,
when compiling/linking.
See also questions
13.25,
13.26,
and
14.2.