1、 Problem Description:
error LNK2019: unresolved external symbol _ WinMain@16 referenced in function ___ tmainCRTStartup
2、 The causes are as follows
1. You build a console program with VC, its entry function should be main, and you use WinMain
2. You use VC to open a. C /. Cpp file, and then directly compile this file, which uses winmian instead of main as the entry function. VC at this time the default setting is for the console program.
3: Solution:
1. Using the main function
Project-> Properties-> C/C++-> Preprocessor-> Preprocessor definitions delete_ Windows, add_ CONSOLE
Project-> Properties-> Linker-> System-> Select console (/ subsystem: console)
for subsystem
2. Using WinMain function
Project-> Properties-> C/C++-> Preprocessor-> Preprocessor definitions delete_ Console, adding_ WINDOWS
Project-> Properties-> Linker-> System-> Select windows (/ subsystem: Windows) for subsystem
(VS2010 test environment)
After the operating system loads the application program, it completes the initialization work and goes to the entry point of the program for execution. The default entry point of the program is actually set by the linker, and different linkers choose different entry functions<
in VC + +, the entry function set by the linker to the console program is maincrtstartup, which calls the main function written by yourself
the entry function for GUI program is winmaincrtstartup, which calls WinMain function written by yourself
the specific entry point is determined by the connector’s/subsystem: option parameter, which tells the operating system how to run the compiled. EXE file
you can specify four methods: “console | windows | national | POSIX”
if the value of this option parameter is “windows”, it means that the application does not need console when it runs. Please refer to MSDN library for detailed description of connector parameter options. The following four combinations can realize the mixed mode of console and windows, which can achieve the effect of not popping up DOS window, and also can output printf information to the console in Windows program
#pragma comment( linker, "/subsystem:windows /entry:WinMainCRTStartup" )
#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )
#pragma comment( linker, "/subsystem:console /entry:mainCRTStartup" )
#pragma comment( linker, "/subsystem:console /entry:WinMainCRTStartup" )
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// ... ...
}
int main(void)
{
// ... ...
}
Similar Posts:
- Error LNK2019: unresolved external symbol WinMain (vs2019)
- [Solved] Run-Time Check Failure #2 – Stack around the variable ‘a’ was corrupted
- [Solved] SSZipArchive Decompress Error: failed to open file in zip file
- Solve the security check error similar to error c4996: ‘scanf’: this function or variable may be unsafe in vs2019
- [Solved] LINK : fatal error LNK1123: failure during conversion to COFF: file
- [Solved] VS error C4996: ‘scanf’: This function or variable may be unsafe.
- How to solve Visual Studio error C4996
- Wins10 install Ubuntu system, error wslregisterdistribution failed with error: 0x8007019e
- Ubuntu Error: Invalid or corrupt jarfile xxx.jar [How to Solve]
- Win10 installs the Ubuntu system and reports an error wslregisterdistribution failed with error: 0x8007019e