Home >Backend Development >C++ >Why am I getting the \'error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup\' error in Visual Studio?
Unresolved External Symbol _main: Resolving the Linker Error
The error "error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup" occurs when the linker cannot find the main() function in your program. This is a critical error that prevents the program from running.
Cause of the Error
In Microsoft Visual Studio, the default subsystem type is set to Windows (GUI). However, if your program uses the console for input and output operations, you need to change the subsystem type to Console. The linker expects the main() function to be the entry point for a console application, so if the subsystem type is incorrect, it cannot find the main() function and generates the error.
Solution
To resolve this error, follow these steps:
Explanation
By changing the subsystem type to Console, you instruct the linker to generate a console executable. This executable will now have the required entry point (main()) for a console application, and the linker will successfully resolve the external symbol.
Note:
The above is the detailed content of Why am I getting the \'error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup\' error in Visual Studio?. For more information, please follow other related articles on the PHP Chinese website!