I am getting complains from Linux GCC about this basic (sample) code - implementation of “circle”.
Obviously something basic is wrong in my usage of sin/ cos.
BUT I do not see it.
What “reference” is missing ? “math” library??
Any help woudl be appreciated and I am sorry for such stupid math question / problem.
Linux GCC linker output
Building target: A_OPEGL_TUT_1
Invoking: GCC C Linker
gcc -o "A_OPEGL_TUT_1" ./src/A_OPEGL_TUT_1.o -lglut -lGL -lGLU
/usr/bin/ld: ./src/A_OPEGL_TUT_1.o: undefined reference to symbol 'sin@@GLIBC_2.2.5'
makefile:30: recipe for target 'A_OPEGL_TUT_1' failed
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Here is the code
GLfloat GL_PI = PI;
glColor3f(1.0f, 1.0f, 1.0f); // white
float width = glutGet(GLUT_WINDOW_WIDTH);
float height = glutGet(GLUT_WINDOW_HEIGHT);
GLfloat x, y, angle,x_offset,y_offset,radius;
//float size = 10;
glColor3f(1, 0, 0); // red
//float size = 25.0;
glPointSize(size);
glBegin( GL_POINTS);
for (angle = 0.0f; angle <= (2.0f * GL_PI); angle += 0.01f) {
x = radius * sin(angle);
y = radius * cos(angle);
// glVertex3f(x, y, 0.0f);
//printf(" x %f y %f \n", x, y);
glVertex2f(x +x_offset, y+y_offset); // 0.0f);
printf(" x %f y %f \n", x, y);
//printf(" window width %f window height %f \n", width, height);
//#endif //sleep(5);
}
glEnd();
glFlush();