How to fix Error LNK2001 unresolved external symbol _mainWCRTStartup?

Ng SG 21 Reputation points
2020-08-28T08:39:44.03+00:00

Hello,

I'm migrating an old project to VS2019. The project originally is created with VS2005.

The migration start with creating a new empty main function as shown:

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
return 0;
}

As I want to run the project with UNICODE , I set the entry point of the project to mainWCRTStartup. I try to compile but failed with error:

1) LNK 2001 unresolved external symbol _mainWCRTStartup
2) LNK 2019 unresolved external symbol __except_handler4_common referenced in function __except_handler4

How can I fix this problem?

Geng

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,519 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
935 questions
{count} votes

Accepted answer
  1. RLWA32 40,021 Reputation points
    2020-08-28T09:37:07.967+00:00

    Remove your setting of the entry point to mainWCRTStartup. This is the wrong name. For a well formed C++ Console application project you can leave that project property blank. The linker will use the correct symbols.

    If you want to set the entry point then it should be wmainCRTStartup for a UNICODE build


1 additional answer

Sort by: Most helpful
  1. Dylan Zhu-MSFT 6,406 Reputation points
    2020-08-31T02:37:28.197+00:00

    Hi Geng,

    You could try to set the Entry Point to "mainCRTStartup ", which also works for console application.

    If it doesn't work, please confirm if the subsystem is "Console" in Project properties-> Linker -> System -> SubSystem.
    21345-annotation-2020-08-31-102628.jpg

    Best Regards,
    Dylan

    0 comments No comments