Linking Error with Minimal Code

This is a discussion on Linking Error with Minimal Code within the Windows Programming forums, part of the Platform Specific Boards category; Code: #include <windows.h> int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { return 0; } That's my program. ...

  1. #1
    Epo
    Epo is offline
    Registered User
    Join Date
    Jun 2003
    Posts
    361

    Linking Error with Minimal Code

    Code:
    #include <windows.h>
    
    int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
    
    	return 0;
    }
    That's my program. Any ideas why I get:

    [ERROR]
    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/E.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
    Creating browse info file...

    E.exe - 2 error(s), 0 warning(s)
    [/ERROR]

    Compiling on MSVC++ 6.0.

    I just have no idea what it can be. I could've sworn this would be the simplest part of the project.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    You are compiling it as a console program instead of a win32 program. That's why it's looking for main() instead of WinMain().

    In your linker settings, you should see the command /subsystem:windows being passed to the linker. You need to change that to /subsystem:console. Either that or just start a new win32 project.

  3. #3
    Epo
    Epo is offline
    Registered User
    Join Date
    Jun 2003
    Posts
    361
    Holy jeez, thanks bithub. I actually restarted the project about 3 times, and each time I must've made it a console app without realizing what I was doing. I wish I could blame lack of sleep, but it's 6:30 in the afternoon.

    That was so much more stressful than it should've been Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 01:48 AM
  2. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  3. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  4. Linking Apache Server Source Code
    By edwardtisdale in forum C Programming
    Replies: 2
    Last Post: 05-19-2002, 04:22 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM

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