Compiler Error

This is a discussion on Compiler Error within the C++ Programming forums, part of the General Programming Boards category; Hi all....so I'm a C++ noob and I'm trying to test some things I've learned, but am getting a compiler ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    3

    Compiler Error

    Hi all....so I'm a C++ noob and I'm trying to test some things I've learned, but am getting a compiler error message I have no clue how to fix.

    Here's the error message:

    1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
    1>P:\C++\Projects\General_Template\Debug\General_T emplate.exe : fatal error LNK1120: 1 unresolved externals
    here is the code being compiled in Visual C++ 2008 Express Edition

    Code:
    // Program1 - A "Sandbox" of sorts
    // to practice C++ in 
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    using namespace std;
    
    //Prototype Declarations
    void WelcomeMessage(void);
    void ExitMessage(void);
    
    int main(int nNumberofArgs, char* pszArgs[])
    {
    	// Display greeting
    	void WelcomeMessage(void);
    	
    	//woo more code goes here
    	
    	
    	// Display Exit Message
    	void ExitMessage(void);
    	
    	system("PAUSE");
    	return 0;
    }
    
    void WelcomeMessage(void)
    {
    	cout << "Welcome, this is my first practical program.\n"
    		 << "IDFK what it does quite yet, but we'll see \n"
    		 << "Have a jolly good day, man \n"
    		 << endl;
    	return;
    }
    
    void ExitMessage(void)
    {
    	cout << "Later, dude! \n"
    		 << endl;
    	return;
    }

    I appreciate any help.

    Cheers

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You need to set up your project to make a command line program, not a Windows program.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    >> void ExitMessage(void);

    You don't call a function the same way it's defined.

    Code:
    int add( int lhs, int rhs )
    {
    	return lhs + rhs;
    }
    
    int main( void )
    {
    	int value = add( 3, 4 );
    }
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    3
    Between the two of you I figured it out.
    Thanks

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,788
    Quote Originally Posted by Chasethesunset View Post
    Hi all....so I'm a C++ noob and I'm trying to test some things I've learned, but am getting a compiler error message I have no clue how to fix.

    Here's the error message:

    1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
    1>P:\C++\Projects\General_Template\Debug\General_ T emplate.exe : fatal error LNK1120: 1 unresolved externals
    Not that it really matters that much, but that's a linker error, not a compiler error.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  6. #6
    Registered User
    Join Date
    Jun 2009
    Posts
    3
    Quote Originally Posted by hk_mp5kpdw View Post
    Not that it really matters that much, but that's a linker error, not a compiler error.
    Oh well, that's good to know anyways. I just called it a comp error cause I got it when I built the solution.

    Thanks again for the help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

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