[I've crossposted this followup -- beware!]
> I'm learning C on a Linux system with gcc 2.7...
> When I try to calculate sin (x) the compiler says:
> undefined reference to 'sin'
> although I wrote
> #include <math.h>
> at the beginning.
line when compiling. You might also want to get ahold of a copy
of the comp.lang.c FAQ list. It answers this question of yours
(question 14.3), so it just might answer your next question, too.
Linux and gcc folks: I know I've asked this before, but why can't
this be fixed in glibc? In 1978 on the PDP-11, there might have
been good reason to leave the math functions out of libc.a, but
surely we could afford to place them there today, especially
since the ANSI C standard says they're just as standard as the
rest of the standard library functions. As it is, gcc+glibc
(and therefore C under Linux) is unnecessarily noncompliant,
unless you argue that "gcc ... -lm" is the standard invocation.
Steve Summit