[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Undefined reference in C

I am using the CDT plugin that lets me use C in Eclipse. I am having one error though, and it is driving me nuts because I can't find the exact answer on google. I am using just one c file, Doodle.c, and here is the beginning of it:

#include <GL/glut.h>
#include <math.h>
#include "Doodle.h"

const double pi2 = 6.28318530718;

void NonlinearMap(double *x, double *y) {
   static double K = 1.04275;
   *y += K * sin(*x);    // (1)
   *x += *y;
   *x = fmod(*x, pi2);    // (2)
   if (*x < 0.0) {
       *x += pi2;
   };
};
..
(there is more to it than this, but this shows plenty).

On the line marked (1), I get the error "Undefined reference to 'sin'". Now this is surprising, because I have the #include <math.h>. Eclipse even has math.h listed in the Outline pane, and I can double click it and math.h opens up. An odd thing is that I cannot find any reference to a sin function in that file. I have exactly the same problem with fmod on the line marked (2). I have identical errors involving anything having to do with GL/glut.h, also included above (same ability to open glut, same inability to find any reference to the involved functions in it). I am reasonably confident of the code because it is example code from a website. Help! I am so clueless!

Marie