PDA

View Full Version : trouble compiling



rolandoo
11-20-2004, 07:47 AM
Hi there! Im pretty new at OpenGL programming but I have a basic question.

I tried to compile the following code:

#include "gl/OpenGLSB.h" // System and OpenGL Stuff

/////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);

// Flush drawing commands
glFlush();
}

/////////////////////////////////////////////////
// Setup the rendering state
void SetupRC(void)
{
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
}

/////////////////////////////////////////////////
// Main program entry point
void main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(800,600);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);

SetupRC();

glutMainLoop();
}

This resulted in error messsages such as:

In function `main':
[Warning] return type of `main' is not `int'
[Linker error] undefined reference to `_imp__glClear'
[Linker error] undefined reference to `_imp__glFlush'
[Linker error] undefined reference to `_imp__glClearColor'

etc. What's the problem???

MikeC
11-20-2004, 09:50 AM
Well, the warning is because you're violating the C++ rule that "main" must be declared as returning int. (Although you don't actually have to return one... don't ask.) The errors are because you aren't linking to the opengl import library (opengl32.lib for Win32). Check your project settings or makefile.

cheers
Mike

rolandoo
11-20-2004, 10:05 AM
What is necessary to change under project settings?
Im using the Bloodshed Dev C++ IDE and under project settings>Paramaters>Linker i pasted the following code:

-mwindows -lglfw -lopengl32 -lglu32

It has worked in previous projects.

rolandoo
11-20-2004, 10:14 AM
OK, I've managed to figure out the problem with the linkers now and managed to compile. But that gave arose to another problem. I have trouble executing the file since the file OPENGL.dll is missing.

Where can I get this file and where shall I place it??

MikeC
11-20-2004, 10:27 AM
Originally posted by rolandoo:
It has worked in previous projects.With the same IDE, the same libs and the same "gl/OpenGLSB.h" header? Odd. -opengl32 is fine; it's what I use in my mingw makefile.

The undefined reference error for "_imp__glClear" etc looks peculiar, because in my copy of libopengl32.a there's no such entry - looking at it in a hex editor, it only has "_glClear" and "__imp__glClear" (note the extra leading underscore).

Hmmm... *scratches head*

rolandoo
11-20-2004, 10:49 AM
No, maybe I havent used the same headears. In previous programs. Nevermind the file is now compiled but not executable.

I'm not sure where to place the OPENGL.dll file??

MikeC
11-20-2004, 11:15 AM
Originally posted by rolandoo:
I'm not sure where to place the OPENGL.dll file??Either in the same dir as your executable, or in the dir as opengl32.dll (normally C:\WINDOWS\SYSTEM32)

Do be aware that opengl.dll is an ancient software-only SGI implementation and nobody really uses it on the Windows platform these days. I believe it'll patch calls through to opengl32.dll if hardware acceleration is available.

So what happened with the link problems? Did you try -lopengl instead, or what? I'm surprised it was installed by default.

rolandoo
11-20-2004, 11:34 AM
I only added one part in the Linker field:

-mwindows -lglfw -lopengl32 -lglu32 -lglut

These linkers were not there by default, I read somewhere that you should when I tried some sample code.

rolandoo
11-20-2004, 11:16 PM
Ok, I still cant execute this very simple program. The source code is:

#include "Common/OpenGLSB.h" // System and OpenGL Stuff
/////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void){
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);
// Flush drawing commands
glFlush();
}
/////////////////////////////////////////////////
// Setup the rendering state
void SetupRC(void){
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
}
/////////////////////////////////////////////////
// Main program entry point
void main(int argc, char* argv[]){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(800,600);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);

SetupRC();
glutMainLoop();
}

I cannot execute because the file OPENGL.dll is missing. I downloaded this file and placed it under Windows/systems32 without success. Please help so that I can go on learning OpenGL