Skip navigation

Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib

This happens if you’re compile/run a Windows app that has a WinMain function, but you chose “Console Application” INSTEAD of
“Windows Application” when you were creating the new project.

You fix this by right clicking on your PROJECT name, then picking the PROPERTIES dialog:
Project Property pages

Then change the subsystem to WINDOWS:
unresolved.gif


NEXT TIME,

to prevent that from happening, make sure you pick WINDOWS APPLICATION at the point where Visual Studio asks you whether you want a console app or a windows app!:

basicwindowsprog1.gif

basicwindowsprog2.gif

21 Comments

    • Anonymous
    • Posted August 29, 2008 at 10:38 pm
    • Permalink

    This helped – thanks!

  1. Thank you!

    • El Ultra
    • Posted November 18, 2008 at 10:15 pm
    • Permalink

    I am new in this deal.
    You helped me.
    thank you, Bobobobo.

    • Anomynous2
    • Posted May 28, 2009 at 3:23 pm
    • Permalink

    This is excellent. Thank you for taking the time to include the images. This is far more detail than I ever expected.

    • Kr L.J.
    • Posted June 3, 2009 at 1:27 pm
    • Permalink

    Thank you~!

    • Anonymous
    • Posted August 3, 2009 at 1:13 am
    • Permalink

    Wahooo thank you! I have been trying for two days to figure out what was wrong with my code, I read other explanations of the error message that said the same thing but I only changed the project options and that didn’t work. Your pictures showing how to create a new GUI project did the trick :) Phew…

    • Wintermute
    • Posted August 17, 2009 at 3:20 pm
    • Permalink

    Thank you!!!

    • Miguel Guerrero
    • Posted September 23, 2009 at 6:44 am
    • Permalink

    dont works!!!

    • Anonymous
    • Posted December 6, 2009 at 7:40 pm
    • Permalink

    not work

    • Anonymous
    • Posted December 12, 2009 at 7:27 pm
    • Permalink

    i tried the two options but this doesn’t work…any idea? :(

    • san
    • Posted February 20, 2010 at 4:34 pm
    • Permalink

    great workaround..:)..

    • Anonymous
    • Posted August 18, 2010 at 2:07 pm
    • Permalink

    Hi … I have two libraries in my project. The first library gets compiled and links without any problem. But I face the above problem while compiling second library and when I changed my application to windows, I see a different linking error now which is “msvcrt.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup” ..any idea how to resolve this ?
    Thanks

    • -S-
    • Posted August 25, 2010 at 1:52 pm
    • Permalink

    <—- Slaps self in face

    • Jean
    • Posted September 28, 2010 at 5:16 am
    • Permalink

    That helped me out.
    Thanks man =]

    • dan_uit
    • Posted October 5, 2010 at 11:18 am
    • Permalink

    Thank you! good job

    • palz
    • Posted November 2, 2010 at 1:12 pm
    • Permalink

    thank’s a lot..

    • Anonymous
    • Posted December 30, 2010 at 5:13 am
    • Permalink

    really helpful – thanks alot

    • Saikou
    • Posted May 11, 2011 at 6:03 pm
    • Permalink

    thanks for helping me out, still have a long way to go to get to know my compiler better, thank you :D

    • CoolDude
    • Posted June 29, 2011 at 10:09 pm
    • Permalink

    It was an excellent one. Thanks man.

    • sumit
    • Posted July 17, 2011 at 10:30 am
    • Permalink

    it don,t work

    • Anonymous
    • Posted April 17, 2012 at 12:37 pm
    • Permalink

    Thanks man!


One Trackback/Pingback

  1. […] way to AVOID this problem is at the time when you choose a project type. The project type should be of type Win32 Project and NOT Win32 Console Application. If Win32 is chosen the error should not bother […]

Leave a comment