Skip to main content
GameDev.net gamedev.net
🔒 Locked

dev cpp never success link with glut

Started by yjh1982 Mar 21, 2005 at 1:34 AM 11 replies 11.4k views
Original Post
yjh1982
yjh1982
I down some opengl sample use dev cpp.but can't build. link error as: [Linker error] undefined reference to `_imp__glutSwapBuffers@0' ..... after a long time,I think this is because glut.but I use http://www.nigels.com/glt/devpak/ OpenGLUT GLUT 3.7.6 FreeGLUT all can't link success . can you help me ?
Drew_Benton
Drew_Benton
You should link with -lglut32. That's about it. If you get more linker errors for OpenGL use:
-lglut32-lglu32-lopengl32
yjh1982
yjh1982
Quote:
Original post by Drew_Benton
You should link with -lglut32. That's about it. If you get more linker errors for OpenGL use:
-lglut32-lglu32-lopengl32


question is:I alrealdy add -lglut32,-lglu32..and so on.

and if use OpenGLUT I add -lopenglut
use freeglut add -lfreeglut....link error is change ,but all like
"[Linker error] undefined reference to..."



Drew_Benton
Drew_Benton
Can you post the errors/code that you are trying to compile. Please use the [source] [/source] tags so it comes out nice and neat [smile]. Alos you might want to take a look at this tutorial. It goes though the process step by step quite clearly. Do that before you post code.
yjh1982
yjh1982
I try it.but can't success on

http://www.cs.uofs.edu/~mpc3/cmps370/glutsetup.html sample:(


glut32.def - Save this file to " C:/dev-c++/lib/ "
.....can use *.def as lib link?


I can't success on any glut sample project ....my dev cpp is 4.9.9.2

Drew_Benton
Drew_Benton
Ok let's go through this step by step.

1. Click here and download the Dev-CPP Devpack. After it is done you will need to find it and install it.
2. When you find it, you should be able to double click on it. A new window will popup with a title of "Installation Wizard".



If that does not happen you will need to follow 2*. If it does, then go to step three.

2.* If you get to here, then the file did not auto open with Dev-CPP. Openup Dev-CPP. Click on "Tools" then "Package Manager". Now choose "Package" then "Install Package". Now you will need to navigate to where you saved the DevPak and select it. You should now see the image from Step 2. Proceed on to step 3 now.

3. Click "Install" then "Finish". Before you close the "Package Manager" window that comes up afterwards, check to make sure you can see the GLUT package.



4. Now you will need to open up Dev-CPP. Choose "File->New->Project". Type in a name for the project and select a "Console Application". Choose a place to save it at.

5. Now delete everything in the "main.cpp" file and copy and paste this code into it:
#include <windows.h>#include <gl\gl.h>#include <gl\glut.h>void init(void);void display(void); int main(int argc, char *argv[]){glutInit(&argc,argv);glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);glutInitWindowSize(250,250);glutInitWindowPosition(100,200);glutCreateWindow("My First Glut/OpenGL Program");init();glutDisplayFunc(display);glutMainLoop();return 0;}void init(void){glClearColor(0.0f ,0.0f ,0.0f ,0.0f);glColor3f(0.0f,0.0f,1.0f);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(45.0f,(GLfloat)250/(GLfloat)250,0.1f,100.0f);}void display(void){glClear(GL_COLOR_BUFFER_BIT);glBegin(GL_TRIANGLES); glVertex3f( 0.0f, 1.0f, -10.0f); glVertex3f(-1.0f,-1.0f, -10.0f); glVertex3f( 1.0f,-1.0f, -10.0f); glEnd();glutSwapBuffers();}


6. Now choose "Project" then "Project Options" and click on the "Parameters" tab. In the linker box type in this order:
-lglut32-lglu32-lopengl32-lglaux-lgdi32-lwinmm




7. Now hit ok. Choose "Execute" then "Compile and Run", and you should see the program.



If you have any questions/comments, feel free to ask. The project can be downloaded here as well.

- Drew
yjh1982
yjh1982
thanks Drew_Benton .
your project is success.

and use your link
-lglut32
-lglu32
-lopengl32
-lglaux
-lgdi32
-lwinmm

replace my link
-lopengl32 -lglu32 -lglut32 -lz(use zlib) -lGdi32

is success!why?because a return line,or winmm/glaux,or link order?
Drew_Benton
Drew_Benton
No problem! I am not entirely sure what was happening with your project. I think your libaries might have gotten corrupted or something, I don't know really. The example that I used had to link in those libraries for some odd reason. Well glad it's working, have fun with GLUT.

- Drew
MaulingMonkey
MaulingMonkey
Quote:
Original post by yjh1982
thanks Drew_Benton .
your project is success.

and use your link
-lglut32
-lglu32
-lopengl32
-lglaux
-lgdi32
-lwinmm

replace my link
-lopengl32 -lglu32 -lglut32 -lz(use zlib) -lGdi32

is success!why?because a return line,or winmm/glaux,or link order?


I'm guessing link order.
Drew_Benton
Drew_Benton
And I just took down the project files and screenshots, They have been reuploaded. So, see if you have missed anything, and if you still can't get it, we can work from there. Give the projecy a try out as well.

- Drew
Drew_Benton
Drew_Benton
Well sorry to hear that! I don't know why that would be happening. I mean you could uninstall your Dev-CPP, get the 4.9.9.2 Beta version and give it another shot and see. I'll leave thet project up for anyone else who needs it. Good luck!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.