VC external symbol error _main _winmain@16 s and s solution

  • 2020-04-02 03:03:05
  • OfStack

This article illustrates the solution of _main, _winmain@16, with the VC external symbol fault. Share with you for your reference. The details are as follows:

When creating an MFC project, do not use the MFC AppWizard wizard. If you do not set the project parameters well, many connection errors will occur during compilation, such as error LNK2001.

Typical error prompts are:

Libcmtd.lib (crt0.obj) : error LNK2001: unresolved external symbol
_main
Libcd-lib (wincrt0.obj) : error LNK2001: unresolved external symbol _winmain@16
MSVCRTD. Lib (crtexew. Obj) : the error
LNK2001: unresolved external symbol _winmain@16
Nafxcwd. Lib (thrdcore. Obj) : the error
LNK2001: unresolved external symbol
__beginthreadex
Nafxcwd.lib (thrdcore.obj) : error LNK2001: unresolved
External symbol __endthreadex n

1. Wrong setting of Windows subsystem, prompt:

Libcmtd.lib (crt0.obj) : error LNK2001: unresolved
External symbol _main

For Windows projects to use the Windows subsystem instead of the Console, you can set this:

[the Project] � > [Settings] � > Select the "Link" property page,
In the Project Options will be/subsystem: the console to/subsystem: Windows  

2. Wrong setting of the Console subsystem

Libcd-lib (wincrt0.obj) : error LNK2001: unresolved
External symbol _WinMain @ 16

The Console project will use the Console subsystem instead of Windows.

[the Project] � > [Settings] � > Select the "Link" property page,

In the Project Options will be/subsystem: Windows to/subsystem: the console

3. Program entry setting is wrong,

Tip:

Msvcrtd.lib (crtexew.obj) : error LNK2001: unresolved external symbol _winmain@16

In general, the program entry function for MFC projects is WinMain,
If you compile the Unicode version of your project, the program entry must be changed to wWinMainCRTStartup, so you need to reset the program entry:

[the Project] � > [Settings] � > Select the "Link" property page,
I'm gonna go to Output in my Category,

Then enter wWinMainCRTStartup in the entry-point symbol

4. Wrong setting of the library when the thread runs.

@ :
KAF n
Nafxcwd.lib (thrdcore.obj) : error LNK2001: unresolved external symbol
__beginthreadex
Nafxcwd.lib (thrdcore.obj) : error LNK2001: unresolved
External symbol __endthreadex

This is because when MFC wants to use multithreading, the library needs to change its Settings:

[the Project] � > [Settings] � > Select the "C/C++" property page,
So in Category, Code Generation,
Select Debug Multithreaded or Multithreaded in the Use run-time library

Single-threaded Single thread static link library (release version)
Multithreaded   Multithreaded static link library (release version)

Multithreaded DLL   Multi-threaded dynamic link library (release version)
The Debug
Single - Threaded   Single-threaded static link library (debug version)
The Debug
Multithreaded   Multithreaded static link library (debug version)
The Debug Multithreaded
DLL   Multi-threaded dynamic link library (debug version)

Single thread: multi-threaded call is not required, multi-purpose in the DOS environment
Multithreading: can be run concurrently
Static library: the library and the program directly Link, you can run away from the MFC library

Dynamic library: the corresponding DLL dynamic library is required for the program to run
Release version: used for official release
Debug version: used during debugging  

Hope that this article described the VC programming for you to help.


Related articles: