| | |
OpenGL in C (errors)
Thread Solved |
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);
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'
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);
c Syntax (Toggle Plain Text)
#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'
Last edited by midimatt; Mar 1st, 2008 at 11:03 am.
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.
Thanks again
EDIT: Found the glut32 lib file i was missing and added that but still getting the same errors as before.
Last edited by midimatt; Mar 1st, 2008 at 11:38 am.
•
•
Join Date: Sep 2006
Posts: 327
Reputation:
Solved Threads: 22
Install the glut devpak
http://www.nigels.com/glt/devpak/
http://www.nigels.com/glt/devpak/
•
•
Join Date: Sep 2006
Posts: 327
Reputation:
Solved Threads: 22
When you create a project did you choose Multimedia > GLUT
This is how to set it up
http://www.zeuscmd.com/tutorials/ope...php#devc++glut
This is how to set it up
http://www.zeuscmd.com/tutorials/ope...php#devc++glut
Last edited by Colin Mac; Mar 1st, 2008 at 11:52 am.
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
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
Last edited by midimatt; Mar 1st, 2008 at 12:01 pm.
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.
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.
Last edited by midimatt; Mar 1st, 2008 at 12:18 pm.
![]() |
Similar Threads
- Using OpenGL in Visual C++: Part I (Game Development)
- Creating a good game (Game Development)
- graphic problem in c (C)
- Nehe Gamedev.net Tutorial Problem: AVI Video in openGL (Game Development)
- OpenGL (Game Development)
- Giving code to posters rather than helping them (IT Professionals' Lounge)
- Dying PC during gaming!! please help! (Troubleshooting Dead Machines)
- Open Gl Programing Error (help)... (Game Development)
- Visual c++ 2005 and OpenGl Problems (Game Development)
Other Threads in the C Forum
- Previous Thread: problem with loop
- Next Thread: Median.c Please Help
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o include incrementoperators input interest kernel kilometer linked linkedlist linux linuxsegmentationfault list lists locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open opensource owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h






