I'm getting Linker errors when trying to compile my OpenGL code with Dev C++, the code compiles perfectly on the university machines using Visual Studio.
I've visited several sites that explain how to get openGL to work om Dev C++, and i've followed the steps.
-Installed the Dev Pack.
-added the glut32.dll file
-changed the parameters in the project options
the parameters are "-lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32" i've tried entering all on same line, i've tried 1 line per parameter but still i get linker errors.
i've hit a brick wall and no idea where to go from here.
Here is the code that i have so far(its for drawing a simple robotic arm);
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
static int shoulder = 0, elbow = 0, wrist = 0, finger1 = 0,finger2 = 0, finger3 = 0;
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef (-1.0, 0.0, 0.0);
glRotatef ((GLfloat) shoulder, 0, 90, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glColor3f(1,1,1);
glutSolidCube (1.0);
glPopMatrix();
glTranslatef (1.0, 0.0, 0.0);
glRotatef ((GLfloat) elbow, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glColor3f(0.9,0.9,0.9);
glutSolidCube (1.0);
glPopMatrix();
glTranslatef (1.0, 0.0, 0.0);
glRotatef ((GLfloat) wrist, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glColor3f(0.8,0.8,0.8);
glutSolidCube (1);
glPopMatrix();
glPushMatrix();
glTranslatef (0.5, 0.0, 0.75);
glRotatef ((GLfloat) finger1, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glColor3f(0.8,0.8,0.8);
glutWireCube (0.75);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef (0.5, 0.0, 0.0);
glRotatef ((GLfloat)finger2, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glColor3f(0.8,0.8,0.8);
glutWireCube (0.75);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef (0.5, 0.0, -0.75);
glRotatef ((GLfloat) finger3, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glColor3f(0.8,0.8,0.8);
glutWireCube (0.75);
glPopMatrix();
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(65.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef (0.0, 0.0, -5.0);
}
void keyboard (unsigned char key, int x, int y)
{
switch (key) {
case 's': /* s key rotates at shoulder */
shoulder = (shoulder + 5) % 360;
glutPostRedisplay();
break;
case 'S':
shoulder = (shoulder - 5) % 360;
glutPostRedisplay();
break;
case 'e': /* e key rotates at elbow */
elbow = (elbow + 5) % 360;
glutPostRedisplay();
break;
case 'E':
elbow = (elbow - 5) % 360;
glutPostRedisplay();
break;
case 'w': /* w key rotates at wrist */
wrist = (wrist + 5) % 360;
glutPostRedisplay();
break;
case 'W':
wrist = (wrist - 5) % 360;
glutPostRedisplay();
break;
case '1':
finger1 = (finger1 - 5) % 360;
glutPostRedisplay();
break;
case '2':
finger2 = (finger2 - 5) % 360;
glutPostRedisplay();
break;
case '3':
finger3 = (finger3 - 5) % 360;
glutPostRedisplay();
break;
default:
break;
}
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
Examples of Errors:
[Linker Error] undefined reference to 'glutinit'
[Linker Error] undefined reference to 'glutmainloop'
[Linker Error] undefined reference to 'glutsolidcube'
[Linker Error] undefined reference to 'glutswapbuffers
[Linker Error] undefined reference to 'glutcreatewindow'