Home >Backend Development >C++ >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'?

Susan Sarandon
Susan SarandonOriginal
2024-12-01 17:02:11783browse

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.

The above is the detailed content of Why Does My C Code Produce 'Error LNK2019: Unresolved External Symbol _WinMain@16'?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn