Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8147515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:22:46+00:00 2026-06-06T14:22:46+00:00

I have the following error: LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

  • 0

I have the following error:

LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

There are a lot of threads relating to this error, but none of those solutions worked for me. And, none explained why this error is here.

I tried:

  • wWinMainCRTStartup as entry point in the linker properties (thread)
  • set the linker to "Windows" (same thread as above)
  • Right click on solution name->Add->Existing Item->file with main (same thread as above)
  • #include <tchar.h> (error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup)
  • try Project + properties, C/C++, Code generation, Buffer security check = No (thread)
  • Options: C/C++, Code generation, Runtime library=/MTd; C/C++, Code generation, Basic Runtime Checks=default; C/C++, Code generation, Buffer security check=No; Linker, Advanced, Entry Point=main (thread)
  • commented out headers in main.cpp except using namespace std and #include <iostream> – results in cascading and snowballing error from functions that referencing those headers
  • I deleted everything in main.cpp except test code, and excluded all source files except main.cpp; as expected it worked, so a small step in the right direction. The problem must be with one of the header files.
  • create new project with Win32 Windows application template (thread and thread)

Have not tried and suspect that these also will not work:

  • use int main() (not sure what they mean, file name or main function name) (thread)
  • using cmake to build on Windows 7 x64 (thread)

Why am I getting this error, and what is the solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:22:48+00:00Added an answer on June 6, 2026 at 2:22 pm

    What is your project type? If it’s a “Win32 project”, your entry point should be (w)WinMain. If it’s a “Win32 Console Project”, then it should be (w)main. The name _tmain is #defined to be either main or wmain depending on whether UNICODE is defined or not.

    If it’s a DLL, then DllMain.

    The project type can be seen under project properties, Linker, System, Subsystem. It would say either “Console” or “Windows”.

    Note that the entry point name varies depending on whether UNICODE is defined or not. In VS2008, it’s defined by default.

    The proper prototype for main is either

    int _tmain(int argc, _TCHAR* argv[])
    

    or

    int _tmain()
    

    Make sure it’s one of those.

    EDIT:

    If you’re getting an error on _TCHAR, place an

    #include <tchar.h>
    

    If you think the issue is with one of the headers, go to the properties of the file with main(), and under Preprocessor, enable generating of the preprocessed file. Then compile. You’ll get a file with the same name a .i extension. Open it, and see if anything unsavory happened to the main() function. There can be rogue #defines in theory…

    EDIT2:

    With UNICODE defined (which is the default), the linker expects the entry point to be wmain(), not main(). _tmain has the advantage of being UNICODE-agnostic – it translates to either main or wmain.

    Some time ago, there was a reason to maintain both an ANSI build and a Unicode build. Unicode support was sorely incomplete in Windows 95/98/Me. The primary APIs were ANSI, and Unicode versions existed here and there, but not pervasively. Also, the VS debugger had trouble displaying Unicode strings. In the NT kernel OSes (that’s Windows 2000/XP/Vista/7/8/10), Unicode support is primary, and ANSI functions are added on top. So ever since VS2005, the default upon project creation is Unicode. That means – wmain. They could not keep the same entry point name because the parameter types are different. _TCHAR is #defined to be either char or wchar_t. So _tmain is either main(int argc, char **argv) or wmain(int argc, wchar_t **argv).

    The reason you were getting an error at _tmain at some point was probably because you did not change the type of argv to _TCHAR**.

    If you’re not planning to ever support ANSI (probably not), you can reformulate your entry point as

    int wmain(int argc, wchar_t *argv[])
    

    and remove the tchar.h include line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following error: Error type - 2: preg_replace() [function.preg-replace]: Compilation failed: missing )
As the title suggests, I am having the following linker error: error LNK2019: unresolved
I use wcsncasecmp inside c/c++ app. Compile have following error: error: 'wcsncasecmp' was not
I have the following error Exception in thread main javax.naming.NameNotFoundException: CounterBean not bound trying
I have the following error when I try to compile my code in g+
When printing a report, the user sometime have the following error: CrystalDecisions.CrystalReports.Engine.LogOnException: Error in
I'm trying to install memcached-1.2.8-repcached-2.2.1 I have the following error after running make :
I have following asp.net code but it gives error when I change dropdown selected
I get the following error in the query below: #1064 - You have an
I keep getting the following error message ERROR 1064 (42000): You have an error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.