none
Unresolved external symbol _mainCRTStartup for Win32 Console project

    Question

  • Hi All,

    I have encountered the "LINK : error LNK2001: unresolved external symbol _mainCRTStartup" problem for my first VC project. After having done some research online and tried out some proposed solutions without luck, I decided to open another post.

    Some additional information about my project:

    1. It's the first project I created after I installed (and reinstall) Microsoft Visual Studio 2010. I haven't changed any settings.
    2. The project is an empty Win32 Console Application. I followed the wizard by File->New->Project->Win32 Console Application, and then checked "Empty project" in the "Application Settings".
    3. In the only test.cpp file I put the following code
      int main()
      {
       return 0;
      }
      but it seems to be irrelevant because I can delete all code and still get the same error message. I guess that the program never got to the .cpp file.
    4. I tried to create a Win32 Console Application following the same routine except not checking "Empty project" option in the setting. I get a _tmain function as the main function, and it compiles!
    5. The error message is pasted below:

    1>------ Build started: Project: TestProject, Configuration: Debug Win32 ------
    1>Build started 11/9/2011 9:27:11 PM.
    1>PrepareForBuild:
    1>  Creating directory "E:\TestProject\Debug\".
    1>InitializeBuildStatus:
    1>  Creating "Debug\TestProject.unsuccessfulbuild" because "AlwaysCreate" was specified.
    1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
    1>E:\TestProject\Debug\TestProject.exe : fatal error LNK1120: 1 unresolved externals
    1>
    1>Build FAILED.
    1>
    1>Time Elapsed 00:00:00.91
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Can someone let me know what might be the cause? I need to create a Win32 Console Project since it's a group project and everyone else are compiling fine.

    Thanks,

    SZ

    Thursday, November 10, 2011 2:47 AM

Answers

  • From the build logs, it looks like test.cpp is not being compiled.

    How did you create this file?

    Have you included this file as part of the project?

    If not right click on the project in Solutions Explorer and select Add -> Existing Item and select test.cpp.


    «_Superman_»
    Microsoft MVP (Visual C++)

    Polymorphism in C
    • Marked as answer by Shaun Z Thursday, November 10, 2011 5:51 PM
    Thursday, November 10, 2011 5:50 AM

All replies