Home >Backend Development >C++ >Why Am I Getting the LNK2019 Error: 'unresolved external symbol _WinMain@16'?

Why Am I Getting the LNK2019 Error: 'unresolved external symbol _WinMain@16'?

Susan Sarandon
Susan SarandonOriginal
2024-12-02 06:29:13476browse

Why Am I Getting the LNK2019 Error:

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

Encountering this linker error while compiling C code can be frustrating. Here's a step-by-step guide to resolve this issue:

Firstly, understand that this error typically occurs when your program doesn't have a proper entry point. In C , the entry point is usually defined by the WinMain function. However, if you're writing code intended for the console, you should use the main function instead.

To fix this issue, follow these steps:

  1. Open your project's properties (right-click on the project in Visual Studio and select Properties from the context menu).
  2. Navigate to the Linker tab, expand System, and then select SubSystem.
  3. Set the SubSystem to Console (/SUBSYSTEM:CONSOLE) instead of Windows (/SUBSYSTEM:WINDOWS).

By changing the Subsystem type, you instruct the linker to create a console application rather than a Windows application. This modification should resolve the unresolved external symbol error you're experiencing.

The above is the detailed content of Why Am I Getting the LNK2019 Error: '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