I've been playing with the gcc compiler. I've written, compiled and run several one-page programs. I just wrote a small program {see below) that uses the trig functions in the math.h library. When I try to compile it, I get an error message. (see below)
Do I need to add something to my path or use different command line options or ?
/*
trigtest.c
*/
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
int main ( int argc, char **argv ) {
double xVal;
double yVal;
double r;
r = 1.0;
xVal = cos( r );
yVal = sin( r );
return 0;
}
tim@optimus:~/src/plot$ gcc trigtest.c
/tmp/ccm1dv69.o: In function `main':
trigtest.c.text+0x1d): undefined reference to `cos'
trigtest.c.text+0x2b): undefined reference to `sin'
collect2: ld returned 1 exit status
tim@optimus:~/src/plot$
Do I need to add something to my path or use different command line options or ?
/*
trigtest.c
*/
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
int main ( int argc, char **argv ) {
double xVal;
double yVal;
double r;
r = 1.0;
xVal = cos( r );
yVal = sin( r );
return 0;
}
tim@optimus:~/src/plot$ gcc trigtest.c
/tmp/ccm1dv69.o: In function `main':
trigtest.c.text+0x1d): undefined reference to `cos'
trigtest.c.text+0x2b): undefined reference to `sin'
collect2: ld returned 1 exit status
tim@optimus:~/src/plot$
Comment