problem with visual c++ 7 : fatal error LNK1561: entry point must be defined

Started by
8 comments, last by TheSeb 18 years, 8 months ago
Hi ! with VC++ 7 i have this error : fatal error LNK1561: entry point must be defined and i don't know what to do. It works well with vc++ 6 but not with vc++ 7. these are my header and my main function :

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <math.h>
#include <string.h>
#include <glew.h>
#include <glut.h>
#include <sdl.h>
//#include <gl.h>
//#include <glext.h>
#include <SDL_image.h>
using namespace std;


#pragma comment( lib,"sdl.lib")
#pragma comment( lib,"sdlmain.lib")
#pragma comment( lib, "SDL_image.lib")
#pragma comment( lib, "glew32.lib")
#pragma comment( lib, "glut32.lib")


int main(int argc, char *argv[])
{
	myLoader= new loader3ds() ;
	glutInit (&argc, argv) ;
	glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH) ;
	glutInitWindowSize (640, 640) ;
	glutInitWindowPosition (250,250) ;
	glutCreateWindow (argv [0]) ;
	glewInit();

	glEnable( GL_DEPTH_TEST );
	glClearColor(0, 0, 1, 0);
	
	myLoader->lighting() ;
	myLoader->loadTextures() ;
	
	glutReshapeFunc (reshape) ;
	
	glutKeyboardFunc (keyboard) ;
	glutDisplayFunc (display) ;
	glutIdleFunc(display);

	loadShader *myShaderLoader = new loadShader("vertexShader.vert", "fragmentShader.frag");
	//loadShader *myShaderLoader = new loadShader("toon.vert", "toon.frag");

	glutMainLoop () ;
	return 0 ;
}

Advertisement
Given your code, the only reason I can think for this happening is if you accidently set the project to build a DLL instead of an EXE. Check your build settings for what kind of target you are outputting. Or just create a new blank application and paste your code in.
If I recall correctly SDL also requires you to compile as "Multithreaded DLL".

SDL replaces your main function with it's own main function provided by sdlmain.lib. The "entry point must be defined" means that the linker can't find the main/winmain function in sdlmain.lib
i have ever set the option as multithreaded DLL :-(
I have created a new blank application and now i have this error :

fatal error C1010: unexpected end of file while looking for precompiled header directive

and the line which is indicated is just after the end of the main function.
To use PCH in MSVC, you have to include the PCH header file before anything else. Another thing to watch out for is that VS will ignore everything in a file before the PCH header.
sorry but what is PCH ? What have i to write ?
PCH stands for precompiled header. When used correctly, they can drastically speed up your compile times.
....[size="1"]Brent Gunning
thanks but what can i do for my problem ?
Go to Project Properties, C/C++, Precompiled Headers and change the setting to not using precompiled headers.
thanks guys it works !

This topic is closed to new replies.

Advertisement