fatal error LNK1561: entry point must be defined

I know, I googled enough to lose all of my hair...

Page 1 of 1

4 Replies - 24986 Views - Last Post: 27 June 2010 - 06:21 AM Rate Topic: -----

#1 Guest_zeldaevolve*


Reputation:

fatal error LNK1561: entry point must be defined

Posted 27 June 2010 - 05:37 AM

#include "SDL_Net.h"

void main(){

	SDL_Init(1);
	SDLNet_Init();

	IPaddress ip;
	TCPsocket tcpsock;
	if(SDLNet_ResolveHost(&ip,NULL,9999)==-1) {
		printf("SDLNet_ResolveHost: %s\n", SDLNet_GetError());
		exit(1);
	}
	tcpsock=SDLNet_TCP_Open(&ip);
	if(!tcpsock) {
		printf("SDLNet_TCP_Open: %s\n", SDLNet_GetError());
		exit(2);
	}

	SDL_Quit();
	SDLNet_Quit();

	return;

}




That's the whole code and it still gave me errors...

1>------ Build started: Project: server, Configuration: Debug Win32 ------
1>Linking...
1>LINK : fatal error LNK1561: entry point must be defined
1>server - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



I already set my linker to runtime library to Multi-threaded DLL (/MD)
and put these : SDL.lib SDLmain.lib SDL_Net.lib on the Additional Dependencies on the linker...

Can someone help me?

Is This A Good Question/Topic? 0

Replies To: fatal error LNK1561: entry point must be defined

#2 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: fatal error LNK1561: entry point must be defined

Posted 27 June 2010 - 05:45 AM

First and first of all, in C++, use int main(). void main() is always wrong. Always.
Secondly, SDL does not like non-parametrized main() function. You have to use:
int main(int argc, char *argv[])


Was This Post Helpful? 1
  • +
  • -

#3 Guest_zeldaevolve*


Reputation:

Re: fatal error LNK1561: entry point must be defined

Posted 27 June 2010 - 06:01 AM

#include "SDL_Net.h"

[i]int main(int argc, char *argv[])[/i]{

	SDL_Init(1);
	SDLNet_Init();

	IPaddress ip;
	TCPsocket tcpsock;
	if(SDLNet_ResolveHost(&ip,NULL,9999)==-1) {
		printf("SDLNet_ResolveHost: %s\n", SDLNet_GetError());
		exit(1);
	}
	tcpsock=SDLNet_TCP_Open(&ip);
	if(!tcpsock) {
		printf("SDLNet_TCP_Open: %s\n", SDLNet_GetError());
		exit(2);
	}

	SDL_Quit();
	SDLNet_Quit();

[i]	return 0;[/i]

}



ok I edited the source and it still gives me the same error...
actually, the 1st thing I did was that to make
int main(int argc, char *argv[])
but it didn't worked for me either so I tried to use void.
Was This Post Helpful? 0

#4 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: fatal error LNK1561: entry point must be defined

Posted 27 June 2010 - 06:06 AM

Ok, then there's something wrong with your project's settings. Did you actually create a Console Application? I think that you have created a Win32 Project instead of a Console. Do this:
Right click on project name -> Properties -> Expand Linker tab -> System -> SubSystem: make sure that it is Console (/SUBSYSTEM:CONSOLE).
Otherwise, re-create the project, but when you create it, make sure that you select Win32 Console Application.
Was This Post Helpful? 1
  • +
  • -

#5 Guest_zeldaevolve*


Reputation:

Re: fatal error LNK1561: entry point must be defined

Posted 27 June 2010 - 06:21 AM

I can only say wow and thanks very much @___@

You really saved me and some of my hair... XD

I'll make it from the beginning then.
Was This Post Helpful? 0

Page 1 of 1