ERN LNK 2019 - How to solve?

2

I'm having a problem with Visual Studio 2017.

This appears when I'm going to compile:

  

LNK2019 undefined external symbol _WinMain @ 16 referenced in function "int __cdecl invoke_main (void)" (? invoke_main @@ YAHXZ) Win32Project2

That was the code I wrote, simple just to start and test if everything was ok.

#include<stdio.h>

int main()
{

    int n = 0;


    scanf_s("%d", &n);

    return 0;
}
    
asked by anonymous 25.05.2017 / 02:13

1 answer

3

You need to mark your project as Console Application. It is interesting to read these two references: Creating a Console Application and Walkthrough: Creating a Standard C ++ Program (C ++) .

There is a response in SO Is it possible to convert the Win32 application project into a console application? . The most voted suggests changing the linker to /SUBSYSTEM:CONSOLE and changing the build macro from _WINDOWS to _CONSOLE .

    
25.05.2017 / 02:36