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'

Ancient Dragon commented: Thanks for taking the time to learn how to use code tags correctly :) +24

Maybe this will help

Maybe this will help

Thanks for the reply, i've looked over the site and although it hasnt solved my problem it has made me think that my problem might be a missing library file so i'm gonna investigate that and see if i can get this program to run for me.

Thanks again


EDIT: Found the glut32 lib file i was missing and added that but still getting the same errors as before.

ALready installed the Devpak, was the first thing i did.

No, i created a blank project because i'm using code that has already been created.

Creating it as an openGL project would have only put the parameters in for me and created a .C file with the correct #includes.

I already have the openGL parameters and the #includes in this project.

EDIT:

After looking at the link you gave me, i'm guessing the only thing i'm missing is a custom makefile but heres the problem

A) i've never made a make file before
B) that website doesnt go into much detail on makefiles

I'm not sure what you mean exactly by using code that has already been created but your code compiled for me after I chose glut.

I wrote in my original post, that i've already writen and compiled the code on a machine at the university using visual studio, i've taken the code home tried to use it on on Dev C++ have been unable to compile,

I've installed the Dev Pak, i've created a blank project and put the code into the blank project.

I've changed the project parameter to include the openGL parameters. which is exactly what happens when you create a glut or openGL project from the multimedia tab.

EDIT: THought to my self maybe i should try and create a glut project, so i have, i've pasted the code in and i'm still getting linker errors

I've been to 4 sites all telling me to do the exact same things, still cant compile after doing those things

EDIT2: i've tried compiling the template code that comes with the glut project, and that also comes up with linker errors.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.