First Program in .Net error LNK2019

Posted on 2004-11-02
Last Modified: 2010-04-24

I am running my first program in .NET on a new computer with .NET just installed.  I am using Visual C++ .NET Step-By-Step.  I am writing the first program, very basic!!

my program:

#include <iostream>
using namespace std;

int main()
      cout <<"Hello, World!" <<endl;
      return 0;

my error:
LIBCD.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup

I think it has to do something with with a registered library, not sure.

Please help!!

Thanks in advance!

Question by:sporenza
    LVL 48

    Accepted Solution

    Create new project of type "Win32 Console Application". Your project has another type, and linker tries to find WinMain function and not main function.
    See also: /SUBSYSTEM linker option. You need /SUBSYSTEM:CONSOLE and not /SUBSYSTEM:WINDOWS.

    Author Comment

    Yes you are correct.  I think I may have drunk too much wine!

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now