0

I setup my OpenGL environment, and tested the Hello world code to make sure everything is working correctly, and they were until...

I wrote this code:

    #ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
#include <iostream>

using namespace std;

//window size and frame rate (60fps)
int width = 600;
int height = 300;
int interval = 1000 / 60;

//Program entry point
int _tmain(int argc, char** argv) {

    //initialize openGL (via glut)
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(width, height);
    glutCreateWindow("My First Video Game (Mushref)");

    //Start the whole thing
    glutMainLoop();
    return 0;
}

After writing this code, I ran the application and it brought this error:

C:\Program Files (x86)\CodeBlocks\MinGW\lib\libmingw32.a(main.o):main.c:(.text.startup+0xa7)||undefined reference to `WinMain@16'|

According to people and other forums, they said "your app should be a console application to run, try changing that", and I have. But it didn't work either on Console or GUI.

What I am trying to do is: program a simple Pong game.

May you please help?

Abdulrahman Mushref
  • 1,012
  • 2
  • 18
  • 40
  • 1
    Why use `_tmain` at all if it's taking `char` instead of `TCHAR`? Even using a compiler that supports this Microsoft extension, it's still pointless over plain `main` because of the parameter. That said, I wouldn't recommend using `T` anything in this day and age. Regardless, perhaps your implementation doesn't support this extension. For more information about the error itself, see [this answer](http://stackoverflow.com/a/5260237/962089). – chris Sep 16 '16 at 18:24
  • Well, that done it, But when I run the console it turns off in a sec... – Abdulrahman Mushref Sep 16 '16 at 18:28
  • That's a different problem. There are plenty of resources that explain how to keep the console window open when running from Code::Blocks. – chris Sep 16 '16 at 18:48
  • I've got it, thank you very much. Here it is so far: http://imgur.com/4PPkqPH – Abdulrahman Mushref Sep 16 '16 at 18:58

0 Answers0