Problem Description
You encounter the following error when compiling a Windows program:
Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
Explanation
This error indicates that the linker cannot find the _main function, which is the entry point for a Windows program. This can occur when the linker is not able to link against the correct library or module that defines _main.
Solution
To resolve this error, check the following:
1. SubSystem Setting:
Open the project properties and ensure that the following settings are correct:
2. Linker Options:
Verify the linker options in Configuration Properties → Linker → General:
Sample Code with Main Function
For clarity, here is a sample code that includes a main function:
int main() { // Your code goes here return 0; }
Additional Notes
The above is the detailed content of Why Am I Getting the 'Error LNK2019 unresolved external symbol _main' in my Windows Program?. For more information, please follow other related articles on the PHP Chinese website!