View Full Version : problem with opengl in dev-c++ and vc ..please help

11-11-2002, 09:00 AM
I using this basic program in Opengl

#include <windows.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 (400, 100) ;
glutInitWindowPosition (100, 100) ;
glutCreateWindow ("First Chapter - Opening an OpenGL Window") ;

init() ;
glutDisplayFunc (display) ;
glutMainLoop () ;
return 0 ;

void init(void)
glClearColor(1.0, 1.0, 1.0, 0.0) ;
glShadeModel(GL_FLAT) ;

void display(void)
glutSwapBuffers() ;

1. In VC++ I have changed the settings to add appropriate libs
winmm.lib,opengl32.lib, glu32.lib, glaux.lib ,glut32.lib...but
when I try to run I get error as

"Cant open include file gl\glut.h" what is the problem?

2. This same program when I try to run in Dev-c++ and enter
proper libs too it compiles successfully but gives out
error as "The TEST_001.EXE file is linked to missing export

what can i do run the program and future programs?

I have glu32.dll and glut32.dll in my
system and system32 dir too.

thanks in advance,

11-11-2002, 09:31 AM
i think I replied to this earlier, you need to set up your compiler correctly. When you import using the <> with include, it looks in a compiler specific directory for that header. Go there and make sure to make a folder called GL then put those headers in it so the compiler can see it.

11-11-2002, 10:21 AM
It may look bizarre, but when I build projects with glut in VC6, I don't need to include opengl32.lib, neither glu32.lib, nor glut32.lib.I just make a console project and get rid of console window.

11-11-2002, 10:32 AM
Same for me. Although I don't use a console application but a win32 project.
Anyway I think the glut.h has all the other headers included for you.

11-11-2002, 10:38 AM
So, you can do some OpenGL graphics with glut and use a win32 project?I didn't know.How you do this?

11-11-2002, 10:43 AM
Glut doesn't come with VC++, so it sounds like you need to download it. Place the header in the vc++/include/GL folder, the .libs in vc++/lib folder, and the .dlls into your windows system or system32 directory.

About not needing to add the .libs when using glut, this is due to the fact that the glut.h has #pragmas that will essentially include the .lib files into the project for you.

11-11-2002, 10:46 AM
errrr well.
Actually I have set up my OpenGL-window without using glut. I just included the glut.h in my project.
Now I am not quite sure what you mean.
Of course you can draw with OpenGL without glut, but then you do exactly that, namely not using glut.
ummm I messed it up, what do you mean?

11-11-2002, 10:46 AM
Smart thing, that glut, isn't it?

11-11-2002, 10:49 AM
Take a look at glut.h. You will see lines that look like so. (Off the top of my head)

#pragma ("lib", "glut32.lib");
#pragma ("lib", "opengl32.lib");
#pragma ("lib", "glu32.lib");
#pragma ("lib", "winmm.lib");

#pragmas are something that is compiler-specific, but I believe the above works both for VC++ and Borland. It's basially an alternative way of including libraries w/o having to go to the project settings to add them to the linker options.

11-11-2002, 10:51 AM
I am using just glut,not OGL with win32, and I don't know if glut can be used in a win32 project without int blahblahblah winmain and blahblahblah wndproc.Can it?

11-11-2002, 10:55 AM
Yes, it can. In fact if you create your Window with glut, you usually shouldn't have the WindowProc. Though, if you create a Win32 Application, the default entry point is still WinMain, so you still need that. But, you don't need to use CreateWindow to create your window. It's usually just more usual to see glut used with a main instead of WinMain, as that keeps it portable.

You can also create a Win32 console, and still use CreateWindow to create your window w/o having a WinMain. In fact, that's essentially what glut does underneath. It sets up it's own WindowProc, calls CreateWindow in the glutCreateWindow, and in the WindowProc when you have callback methods for things setup, it will call them from the WindowProc when those events occur.

And if you create your window using CreateWindow and the WindowProc stuff, you can still use glut for things like glutTeapot, etc.

And in case my previous response wasn't clear, you only need to #include <GL/glut.h> in order for those #pragmas to take effect. Those have nothing to do with how you actually create the window.

Edits: Tried to clarify some things.

[This message has been edited by Deiussum (edited 11-11-2002).]

11-11-2002, 11:00 AM
I am using just glut,not OGL with win32, and I don't know if glut can be used in a win32 project without int blahblahblah winmain and blahblahblah wndproc.Can it?

11-11-2002, 11:16 AM
I am using just glut,not OGL with win32, and I don't know if glut can be used in a win32 project without int blahblahblah winmain and blahblahblah wndproc.Can it?

11-12-2002, 08:38 AM
the vc problem is over.....i added three lines to object/library modules in project settings ..
opengl32.lib glu.lib glut.lib
and for now its solved...