LINK : fatal error LNK1561: entry point must be defined

This is a discussion on LINK : fatal error LNK1561: entry point must be defined within the C++ Programming forums, part of the General Programming Boards category; I'm trying to compile some code from a book, I have set all the correct linker and compiler options for ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    18

    LINK : fatal error LNK1561: entry point must be defined

    I'm trying to compile some code from a book, I have set all the correct linker and compiler options for SDL libs and headers. But I get this error:
    LINK : fatal error LNK1561: entry point must be defined

    This is my code:

    Code:
    #include <SDL.h>
    int main (int argc, char* argv[]) {
    	if (SDL_Init( SDL_INIT_VIDEO ) < 0)
    		return -1;
    	SDL_WM_SetCaption("Hello World", "Hello World");
    	SDL_Surface* screen = SDL_SetVideoMode(640,480, 0, 0);
    	SDL_Surface* temp = SDL_LoadBMP("data\\textures\\sdl_logo.bmp");
    	SDL_Surface* bg = SDL_DisplayFormat(temp);
    	SDL_FreeSurface(temp);
    	SDL_Event event;
    	bool quit = false;
    	while (!quit)
    	{
    		if (SDL_PollEvent(&event))
    		{
    			switch (event.type)
    			{
    			case SDL_QUIT:
    				quit = true;
    			break;
    			case SDL_KEYDOWN:
    				switch (event.key.keysym.sym)
    				{
    				case SDLK_ESCAPE:
    					quit = true;
    				break;
    				}
    			break;
    			}
    		}
    		SDL_BlitSurface(bg, NULL, screen, NULL);
    		SDL_UpdateRect(screen, 0, 0, 0, 0);
    	}
    	SDL_FreeSurface (bg);
    	SDL_Quit();
    	return 0;
    }
    Check out my blog!
    http://www.om3ga.co.uk

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    That's odd. I wonder if something in the SDL header isn't screwing with the main() definition.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    what type of project did you set it up as? Did you try a console application?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    Tried a console application. I'm using MSVC++ 2005 Express, I tried both Win32 Console App and CLR Console App, but neither worked.

    Any other ideas?

    -Ben
    Check out my blog!
    http://www.om3ga.co.uk

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    msvc 2005 defines UNICODE by default and therefore implicitly uses the wide character variants of main and WinMain (wmain and wWinMain) as entry points. Try disabling unicode and rebuilding.

    project menu --> project options --> configuration properties --> General, change character set to 'not set'.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    Registered User
    Join Date
    Aug 2006
    Posts
    12
    What happens if you comment everything except

    Code:
    int main (int argc, char* argv[]) 
    {
    	return 0;
    }
    What is the value of Entry Point and No Entry Point fields in Project Properties --> Linker --> Advanced panel?

  7. #7
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    Thanks, but it didn't work, it was already set to "Not set", I tried it on Unicode and Multi-Byte, but neither worked.

    -Ben
    Check out my blog!
    http://www.om3ga.co.uk

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    It's stopped giving me that previous error, and now gives this:
    ------ Build started: Project: SDLHelloWorld, Configuration: Debug Win32 ------
    Compiling...
    main.cpp
    Linking...
    LINK : error LNK2001: unresolved external symbol _main
    main.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_UpdateRect referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_UpperBlit referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_PollEvent referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_FreeSurface referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_DisplayFormat referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_LoadBMP_RW referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_RWFromFile referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_WM_SetCaption referenced in function _SDL_main
    main.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main
    C:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\Debug\SDLHelloWorld.ex e : fatal error LNK1120: 12 unresolved externals
    Build log was saved at "file://c:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\SDLHelloWorld\Debug\Bu ildLog.htm"
    SDLHelloWorld - 13 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Viorel: I tried that, and it gave the error LINK : error LNK2001: unresolved external symbol _main

    The value of entry point was blank, but i changed it to "main", and No Entry Point is No

    -Ben
    Check out my blog!
    http://www.om3ga.co.uk

  9. #9
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    Ok, seems that I hadn't linked SDL.lib and SDLmain.lib properly. Now I get this:

    ------ Build started: Project: SDLHelloWorld, Configuration: Debug Win32 ------
    Linking...
    LINK : fatal error LNK1104: cannot open file 'uuid.lib'
    Build log was saved at "file://c:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\SDLHelloWorld\Debug\Bu ildLog.htm"
    SDLHelloWorld - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


    I tried setting Ignore Specific Library to "uuid.lib", but that gave this:

    ------ Build started: Project: SDLHelloWorld, Configuration: Debug Win32 ------
    Linking...
    MSVCRT.lib(MSVCR80.dll) : error LNK2005: _exit already defined in LIBCMT.lib(crt0dat.obj)
    MSVCRT.lib(MSVCR80.dll) : error LNK2005: __isctype already defined in LIBCMT.lib(isctype.obj)
    LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    C:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\Debug\SDLHelloWorld.ex e : fatal error LNK1169: one or more multiply defined symbols found
    Build log was saved at "file://c:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\SDLHelloWorld\Debug\Bu ildLog.htm"
    SDLHelloWorld - 3 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Any ideas?

    -Ben
    Check out my blog!
    http://www.om3ga.co.uk

  10. #10
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,511
    Well, certainly you wouldn't expect it to work if you set your linker to ignore a library it is asking for...

    LINK : fatal error LNK1104: cannot open file 'uuid.lib'
    Do you have have the Platform SDK installed?
    Last edited by Mario F.; 08-09-2006 at 06:17 AM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  11. #11
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    Ok, got rid of the ignore, added the platform sdk path to the library and include lists, now i get this:
    ------ Build started: Project: SDLHelloWorld, Configuration: Debug Win32 ------
    Linking...
    MSVCRT.lib(MSVCR80.dll) : error LNK2005: _exit already defined in LIBCMT.lib(crt0dat.obj)
    MSVCRT.lib(MSVCR80.dll) : error LNK2005: __isctype already defined in LIBCMT.lib(isctype.obj)
    LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    C:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\Debug\SDLHelloWorld.ex e : fatal error LNK1169: one or more multiply defined symbols found
    Build log was saved at "file://c:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\SDLHelloWorld\Debug\Bu ildLog.htm"
    SDLHelloWorld - 3 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    -Ben
    Check out my blog!
    http://www.om3ga.co.uk

  12. #12
    Registered User
    Join Date
    May 2006
    Posts
    903
    There you go.
    Quote Originally Posted by om3ga
    Ok, got rid of the ignore, added the platform sdk path to the library and include lists, now i get this:
    ------ Build started: Project: SDLHelloWorld, Configuration: Debug Win32 ------
    Linking...
    MSVCRT.lib(MSVCR80.dll) : error LNK2005: _exit already defined in LIBCMT.lib(crt0dat.obj)
    MSVCRT.lib(MSVCR80.dll) : error LNK2005: __isctype already defined in LIBCMT.lib(isctype.obj)
    LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    C:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\Debug\SDLHelloWorld.ex e : fatal error LNK1169: one or more multiply defined symbols found
    Build log was saved at "file://c:\Documents and Settings\EVAL\My Documents\Visual Studio 2005\Projects\SDLHelloWorld\SDLHelloWorld\Debug\Bu ildLog.htm"
    SDLHelloWorld - 3 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    -Ben

  13. #13
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    No, that's a poor solution.

    The problem here is that the SDL libs were compiled using a different runtime library setting than your program. Experiment with the runtime library setting in the general options. My best guess is to use multi-threaded static non-debug.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  14. #14
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    Ok, Multi-threaded DLL works. It gave me an error then about SDL.dll, so I moved SDL.dll to the debug folder inside my project folder, now I get a console window, then this error in a message box with the options "break" and "continue":
    Unhandled exception at 0x00401139 in SDLHelloWorld.exe: 0xC0000005: Access violation reading location 0x08c6f99c.

    -Ben
    Check out my blog!
    http://www.om3ga.co.uk

  15. #15
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Well, choose break and look at what the debugger tells you.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  2. Variables already defined while linking.
    By xconspirisist in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2005, 05:20 AM
  3. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 06:16 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. mmsystem.h and link error
    By swordfish in forum Windows Programming
    Replies: 5
    Last Post: 09-20-2001, 11:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21