OpenGL/GLUT linking problem

Feb 4, 2013 at 5:04am
I have some C++ code that uses OpenGL and GLUT. When I try to compile it, it gives me the following result:
Warning: resolving _glEnable@4 by linking to _glEnable
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _glShadeModel@4 by linking to _glShadeModel
Warning: resolving _glClearColor@16 by linking to _glClearColor
Warning: resolving _glClear@4 by linking to _glClear
Warning: resolving _glMatrixMode@4 by linking to _glMatrixMode
Warning: resolving _glLoadIdentity@0 by linking to _glLoadIdentity
Warning: resolving _glPushMatrix@0 by linking to _glPushMatrix
Warning: resolving _glTranslated@24 by linking to _glTranslated
Warning: resolving _glColor3f@12 by linking to _glColor3f
Warning: resolving _glPopMatrix@0 by linking to _glPopMatrix
Warning: resolving _glViewport@16 by linking to _glViewport
Warning: resolving _gluPerspective@32 by linking to _gluPerspective
Warning: resolving _glLineWidth@4 by linking to _glLineWidth
Warning: resolving _glBegin@4 by linking to _glBegin
Warning: resolving _glVertex3f@12 by linking to _glVertex3f
Warning: resolving _glEnd@0 by linking to _glEnd
Warning: resolving _gluLookAt@72 by linking to _gluLookAt


When I run the executable, I do not even see a window before it crashes. When I try to print out something as the first line of code, I do not see that appear.

I want to note that I have looked all around for the same problem, but all of the solutions that apparently worked for other people have not worked for me.

I am running Windows 7 x64. I compiled this with the Eclipse IDE, and I included opengl32, glu32, and glut32 (the libraries) in that order.

I successfully was able to compile the exact same code using Eclipse on Linux Mint x86, so it is not the code.

If anyone has a solution, please let me know. Thanks.
Feb 4, 2013 at 6:33am
I think maybe the libraries that worked on linux aren't the same as the ones used by windows. So you have to find the same ones for windows and compile using those. For example you will need opengl32.dll on windows not the opengl32.lib for linux
Feb 4, 2013 at 7:39am
I think you should reverse libraries order.
first glut, then glu and then gl.

BTW, you must copy those lib files in lib directory of your compiler and corresponding dlls in system directory.
check file extension. if it is .c change it to .cpp or vice versa. It seems linker encountered a problem with name mangling.
Feb 4, 2013 at 11:20pm
@Smac89
Yes, I do know this, but I am sure I have the right libraries.

@majidkamali370
I tried this already, it did not work.
Feb 4, 2013 at 11:22pm
closed account (S6k9GNh0)
We don't know how you're opening a window or the rest of your program. Care to provide a test case?
Feb 4, 2013 at 11:23pm
What do you mean by "included" the libraries?
Feb 4, 2013 at 11:29pm
@iHutch105
By included, I mean as a compile option I used -lopengl32, to include the opengl library. Normally if the compiler had a problem finding opengl32, it would give an error about that, but it didn't, so I know that including the libraries works just fine..
Feb 4, 2013 at 11:32pm
@computerquip
1
2
3
4
5
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowSize(500, 500);
	glutInitWindowPosition(0, 0);
	glutCreateWindow("Change later");

Is how I open a window. As I stated in the first post, the entire program runs just fine on Linux Mint, but will crash on start-up when I use Windows 7. I believe it is something to do with linking the libraries, possibly an outdated library, although I'm pretty sure that I'm using the latest versions of everything.
Last edited on Feb 4, 2013 at 11:37pm
Feb 4, 2013 at 11:34pm
I don't think order of "library inclusion" matters. Perhaps something with Eclipse's libraries? Try using it with a clean reinstall of MinGW.
Feb 5, 2013 at 1:51am
> I don't think order of "library inclusion" matters
There are cases. It could give you `undefined reference'.

@OP: Debugger, backtrace.

Edit: see `Auto-import' http://gnuwin32.sourceforge.net/compile.html
Last edited on Feb 5, 2013 at 2:04am
Feb 5, 2013 at 4:03pm
does Eclipse use gcc?
In gcc this is the command for compiling and linking.
g++ myProgram.cpp -lglut -lGLU -lGL
this command is case sensitive.
Feb 6, 2013 at 11:45pm
I was fooling around with stuff, and then realized that it didn't just have to be a problem with GLUT. I tried compiling just a simple "Hello World" application, and it compiled. When I tried to run it, however, it just gave me the error
The program can't start because libgcc_s_dw2-1.dll is missing from your computer.  Try reinstalling the program to fix this problem.

This looks like it could be a problem with MinGW maybe? I have never had this problem in my three years of programming before. I googled it and couldn't seem to find anything.

Remember, this is when I'm trying to compile a simple hello world application that I know works.
Feb 7, 2013 at 12:08am
Here maybe?
http://stackoverflow.com/questions/4702732/the-program-cant-start-because-libgcc-s-dw2-1-dll-is-missing

The libgcc_s_dw2-1.dll should be in the compiler's bin directory. You can add this directory to your PATH environment variable for runtime linking, or you can avoid the problem by adding "-static-libgcc -static-libstdc++" to your compiler flags.
Feb 7, 2013 at 1:15am
Yes, thank you, that worked.
Topic archived. No new replies allowed.