"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Does My C++ Code Produce "Error LNK2019: Unresolved External Symbol _WinMain@16"?

Why Does My C++ Code Produce "Error LNK2019: Unresolved External Symbol _WinMain@16"?

Posted on 2025-02-07
Browse:742

Why Does My C   Code Produce

Resolving "Error LNK2019: Unresolved External Symbol _WinMain@16 Referenced in ___tmainCRTStartup"

While attempting to execute a basic code snippet, you may encounter the following error:

error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

Cause:

This error occurs because the linker cannot resolve the undefined symbol _WinMain. This symbol typically refers to the main entry point function for a Windows application.

Solution:

To resolve this issue, follow these steps:

  1. Open your Visual Studio project's Properties window.
  2. Navigate to Linker > System.
  3. Under SubSystem, change the setting from Windows (/SUBSYSTEM:WINDOWS) to Console (/SUBSYSTEM:CONSOLE).

This modification will ensure that your code compiles as a console application instead of a Windows application, thus resolving the linker error.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3