Thread: Hello World

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    361

    Hello World

    I am wondering why this code won't compiler properly.
    Code:
    // Windows programming.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include <windows.h>
    
    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    	MessageBox(NULL, "Hello world!", "Sample", MB_OK);
    	return 0;
    }

    These are the errors I get.



    --------------------Configuration: Windows programming - Win32 Debug--------------------
    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/Windows programming.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    Windows programming.exe - 2 error(s), 0 warning(s)


    I undefined _CONSOLE like the tutorial said to, but I still get those errors.

    I am using MCVC++.
    Last edited by Glirk Dient; 07-28-2003 at 01:12 PM.

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    361
    Now I get this

    Compiling resources...
    Compiling...
    Windows Tutorial.cpp
    c:\dxsdk\samples\c++\direct3d\windows tutorial\windows tutorial.cpp(9) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.

    Windows Tutorial.exe - 1 error(s), 0 warning(s)

    Alright, I selected empty win32 project instead of the Hello WOrld and placed my code where it said to, and used their main() and everything else...guess thats what was wrong.

    This is the main() that I am now using.

    int APIENTRY WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)

    Hope this can at least help others with the same problem.
    Last edited by Glirk Dient; 07-28-2003 at 02:08 PM.

  3. #3
    ‡ †hë Ö†hÈr sîÐè ‡ Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299
    project > propertys
    c/c++ > precompiles headers
    beside create/use precompiled header
    select Not Using Precompiled Headers
    this is for visual c.net
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    361
    Ohhh, wow...I turned them off and now the original code works! Thanks a lot!

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Ohhh, wow...I turned them off and now the original code works! Thanks a lot!
    I don't get it. How can this code work:

    Code:
    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    	MessageBox(NULL, "Hello world!", "Sample", MB_OK);
    	return 0;
    }
    The function header doesn't have names for the parameters.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Oh, I didn't know that, sorry.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The 7 New Wonders of the World
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 36
    Last Post: 12-08-2006, 01:55 PM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  4. Too much to ask ?
    By deflamol in forum C Programming
    Replies: 2
    Last Post: 05-06-2004, 04:30 PM
  5. No More Technology After World War Three
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-20-2001, 07:02 PM