views:

180

answers:

2

I am studying graphics and currently using OpenGL with GLUT. Doing my editing in codeblocks and using an online tutorial located at lighthouse3d. I am using the main method declared on that page however it will not let me compile. The error message consists of the main method not returning an int, I have "played" with the code enough to say I am confused. The GLUT Library is installed, and I do not see where the error is coming from.

Thank you, Zach Smith

+2  A: 

You probably have a method like this:

void main(int argc, char** argv) {
    // The code...
}

Change it to this:

int main(int argc, char** argv) {
    // The code...
    return 0;
}
Adam Paynter
+1 http://users.aber.ac.uk/auj/voidmain.shtml
ephemient
If I do this many other errors come up. Here are some examples of the errors...C:\Users\Zach\Desktop\OpenGL_Robot\robot.o:robot.cpp:(.text+0x1c)||undefined reference to `___glutInitWithExit@12'|C:\Users\Zach\Desktop\OpenGL_Robot\robot.o:robot.cpp:(.text+0x5d)||undefined reference to `___glutCreateMenuWithExit@8'|
Zach Smith
@Zach: I only know enough to help you with your original question. I recommend you create another question to deal with your other errors.
Adam Paynter
Either you're missing a library (glut.lib) or you've flipped the load order around.
knight666
Small point: You don't really need to return 0 in openGL. After you call glutMainLoop(), everything is handled by the Event Handler.
SauceMaster
+1  A: 

The problem is that you are not linking the needed libraries.

Go to the project properties by right clicking on the project icon in the 'Solution Explorer' and click on 'Properties'. Then go under 'Configuration Properties' -> 'Linker' -> 'Input' and add the following libraries to the 'Additional Dependencies' field:

opengl32.lib glut32.lib glu32.lib

Rebuild your project and all should be fine!

mrucci