Followers 0

Help me with that error please!

8 posts in this topic

Hello everyone,

I'm learning Nehe tutorials and I came across with an error: "entry point must be defined" file: "LINK"

This is my code:

#include <Windows.h>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\GLAux.h>

HGLRC           hRC = NULL;
HDC             hDC = NULL;

bool keys[256];
bool active = TRUE;
bool fullscreen = TRUE;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
{
if (height == 0)
{
height = 1;
}

glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);

gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f);

glMatrixMode(GL_MODELVIEW);
}

int InitGL(GLvoid){
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
return TRUE;
}



Help me to figure it out please

0

Share on other sites

The "entry point" is also known as main function. Under Windows this is usually WinMain(…), while under unixes it is usually main(…). Without such a function anywhere within your code, the compiler does not know what to call when the OS hands over program execution to your executable. Either you complete the shown code snippet by an appropriate main function, or else you need to compile it as object file and link it with another object file where the main function was compiled into.

I still not sure what to do. if you could explain me in more details I will be very glad.

Thank you

0

Share on other sites

I would recommend downloading the finished code that you can find at the end of each tutorial, and comparing it to your code.

1

Share on other sites
What part of haegarr's reply are you having difficulty with?

You need to add a main() / WinMain() function, probably the latter given that you have declared WndProc(). Given that you saying you're following NeHe, have you fully read the first tutorial? There is a WinMain() implementation in it. It appears you're only using the first portion of the code, it is all necessary to have a complete, runnable program.
2

Share on other sites
I still not sure what to do. if you could explain me in more details I will be very glad.

Telling you what exactly to do requires knowledge of your project set-up. Moreover I'm not a Windows programmer but one working under Unix.

However, in principle you need to implement a function WinMain (because you're building a Windows executable). The legacy NeHe tutorials have this function explained in tutorial 01, and I assume that the tutorials you are following have this, too. Later tutorials may have dropped it for clarity, but when you download the tutorial instead of copying it from screen you probably found WinMain therein. I don't know which tutorials / source you are following, so I cannot hint you exactly where to look.

EDIT: Being ninja'd twice… ;)

Edited by haegarr
1

Share on other sites

As everyone else has mentioned, you need an entry point.  Otherwise, where does the program start?  Seeing as you declared a message proc, you want:

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow ) {

//Do stuff here.

return 0;
}


You will also need to check the message queue and handle those messages in the main function.

1

Thanks everyone

0

Create an account

Register a new account