Help me with that error please!

Started by
7 comments, last by Kaptein 9 years, 11 months ago

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

Advertisement

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.

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

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

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.
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… ;)

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.

"The code you write when you learn a new language is shit.
You either already know that and you are wise, or you don’t realize it for many years and you are an idiot. Either way, your learning code is objectively shit." - L. Spiro

"This is called programming. The art of typing shit into an editor/IDE is not programming, it's basically data entry. The part that makes a programmer a programmer is their problem solving skills." - Serapth

"The 'friend' relationship in c++ is the tightest coupling you can give two objects. Friends can reach out and touch your privates." - frob

Thanks everyone

Also NeHe's tutorials are SEVERELY outdated to the point of being completely irrelevant today.

There are better modern tutorials out there.

For example:

http://www.arcsynthesis.org/gltut/

This topic is closed to new replies.

Advertisement