Tip: Turning Win32 Console app to non-Console app

September 30, 2013

no comments

Let’s say you’ve created a Win32 Console Application in Visual Studio:


We get the classic main function.

Now suppose that after working on the project for a while we want to turn the app into a Windows app – no console. At first, this seems easy: just replace the main function with a proper WinMain:

  1. int _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR lpCmdLine, int nCmdShow)

Unfortunately, that’s not enough. Building the project produces the following linker error:

MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

The linker still expects a main function.

The solution is (apart from creating a new project, adding the files, making any changes to the project again) is to switch the subsystem by using the Linker / System property tab and changing SubSystem to Windows (instead of Console):


And voila! The project links successfully.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>