Home » Community » Forums » General Programming » dev cpp never success link with glut
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 dev cpp never success link with glut
Post New Topic  Post Reply 
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 ?

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

You should link with -lglut32. That's about it. If you get more linker errors for OpenGL use:
-lglut32
-lglu32
-lopengl32


 User Rating: 1933   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

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..."





 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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 . 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.

 User Rating: 1933   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

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



 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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

 User Rating: 1933   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

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?

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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

 User Rating: 1933   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

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.

 User Rating: 1866   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

i have a similar problem - i get the same linker errors. i have tried all the linker flags. i have checked - the libraries are there, the header files are there. i do EXACTLY what drew says. yet the errors do not go away. can someone help me?

 User Rating: 1015    Report this Post to a Moderator | Link

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

 User Rating: 1933   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

thanks drew. the error remains :( i do not know. i am giving up. you can take down the project.

w.

 User Rating: 1015    Report this Post to a Moderator | Link

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!

 User Rating: 1933   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: