[OCLUG-devel] math functions in C
Thomas Moore
thomasmoore at speakeasy.net
Tue Nov 9 23:38:43 PST 2004
Hi all,
I have only been on this list for a short time but
have never seen a posting. But I will anyway. I am
not a programmer but do write small programs for
my amusement.
Here is a short C program to illustrate my
problem:
#include <stdio.h>
#include <math.h>
int main(void)
{
double x = .7854;
double y;
y = sin(x);
printf("sin(%f) = %f\n\n", x, y);
}
Then doing
gcc -o prog prog.c
I get the following message:
/tmp/ccZW5o7k.o(.text+0x1a): In function `main':
: undefined reference to `sin'
collect2: ld returned 1 exit status
Now, math.h refers to mathcall.h which contains
all the function prototypes. Why will this not
compile? Or more to the point, what am I doing
wrong?
Thanks.
Tom
More information about the OCLUG-devel
mailing list