Home >Backend Development >C++ >Why Does My C Project Show 'Unresolved External Symbol: _WinMain@16' and How Can I Fix It?

Why Does My C Project Show 'Unresolved External Symbol: _WinMain@16' and How Can I Fix It?

Linda Hamilton
Linda HamiltonOriginal
2024-12-01 09:03:14408browse

Why Does My C   Project Show

Unresolved External Symbol: _WinMain@16 Using Visual Studio

When attempting to compile and execute a simple C program involving a generic Stack class, you may encounter the following errors:

  • MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

This issue arises due to a linker problem caused by an incorrect setting in Visual Studio. Here's the solution:

Changing SubSystem Setting in Visual Studio

  1. Open your Visual Studio project and navigate to the "Properties" pane.
  2. Under "Configuration Properties," expand "Linker" and select "System."
  3. Locate the "SubSystem" option. By default, it is likely set to "Windows (/SUBSYSTEM:WINDOWS)."
  4. Change the setting to "Console (/SUBSYSTEM:CONSOLE)."

This adjustment instructs the linker to use the console subsystem for the application, rather than the Windows subsystem. This resolves the issue of the unresolved external symbol _WinMain@16, which is required for console-based applications.

After making this change, rebuild your project and run it. The errors should no longer occur.

The above is the detailed content of Why Does My C Project Show 'Unresolved External Symbol: _WinMain@16' and How Can I Fix It?. 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