Thread: Win Main link error

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    25

    Win Main link error

    Okay. Im try to make a very simple windows program from the intro to windows programming in the opengl section of tutorials on this site. This is the program:

    Code:
    #include <windows.h>
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
     	
    	MessageBox(NULL, "\tHello World!", "My first windows app", NULL);
    	return 0;
    }
    When I try to run it with VC++ 6, I get the following linker errors:

    error LNK2001: unresolved external symbol _main
    fatal error LNK1120: 1 unresolved externals
    Its odd because it compiles fine, too!

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Make a Win32 Application, not a Win32 Console Application.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    25
    Gah, stupid VC++. I normally open up the .cpp file, not the other project files it likes to create(cause i work a lot with notepad) and I think it defaults to opening it as a console app. Is there a way to change the default it opens it as?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  3. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM