0

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 Answers 2

2

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; } 
Sign up to request clarification or add additional context in comments.

4 Comments

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: I only know enough to help you with your original question. I recommend you create another question to deal with your other errors.
Either you're missing a library (glut.lib) or you've flipped the load order around.
Small point: You don't really need to return 0 in openGL. After you call glutMainLoop(), everything is handled by the Event Handler.
2

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!

1 Comment

Agreed. You've not assigned libraries to your project. If you are using GCC compiler, you should assign "glut32.a" as mrucci answered. Note: not ".lib", but ".a" files! BUT if your compiler of choice is VisualStudio' one - do as described above.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.