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

Developer technologies | Visual Studio | Debugging
Developer technologies | C++
Developer technologies | 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.
{count} votes

Answer accepted by question author
  1. RLWA32 51,536 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,431 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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.