Sign in to follow this  

Help me with that error please!

This topic is 1354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);                        
	glLoadIdentity();                           

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

	glMatrixMode(GL_MODELVIEW);                   
	glLoadIdentity();                        
}

int InitGL(GLvoid){
	glShadeModel(GL_SMOOTH);
	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

 

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this