Answered LINK : error LNK2001: unresolved external symbol _mainCRTStartup

  • Tuesday, May 24, 2011 5:51 AM
     
     

    ------ Build started: Project: vball, Configuration: Debug Win32 ------

    1>Build started 24-May-11 11:12:32 AM.

    1>InitializeBuildStatus:

    1> Touching "Debug\vball.unsuccessfulbuild".

    1>ManifestResourceCompile:

    1> All outputs are up-to-date.

    1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup

    1>c:\users\sv\documents\visual studio 2010\Projects\vball\Debug\vball.exe : fatal error LNK1120: 1 unresolved externals

    1>

    1>Build FAILED.

    1>

    1>Time Elapsed 00:00:02.64

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    code compiled was

    #include<iostream>

    using namespace std;

    int main()

    {

    cout<<"Hello !";

    return 0;

    }

    i even tried compiling using vs command prompt but even there also following errors occured

    C:\program files(x86)\Microsoft visual studio 10.0\VC\INCLUDE\cmath(19) : error c2061 : syntax error : identifier 'acosf';

    like above more than 100 errors occured.

All Replies

  • Tuesday, May 24, 2011 9:02 AM
     
     Answered

    From the description of your issue, I assume, you created an empty project.
    If you want to build a c++ project from scratch do:
    In the project wizard go to Projects Types and check Empty Project option (for me its under Visual C++ General). Important: no clr support). Add a file say vball.cpp to your project (because compiler then uses c++, which you need, when using cout. When file is ending with plain c, VS thinks, it is only c-code, and you get these acosf errors). Copy your code into this file. Try a new build and run.

    But for beginners, it is far better, to use the wizards to build new projects, in your case, a console-application would be a good choice. Also you ended up with your thread in VS-Debugger Forum which handles debugger problems. For issues like yours, either
    Visual C++ General or Visual C++ Language
    http://social.msdn.microsoft.com/Forums/en-US/category/visualc
    are much better suited.

    with kind regards

  • Sunday, September 25, 2011 6:24 PM
     
     

    I've been having this problem creating empty Win32 console applications from the wizard. I discovered that when you check "Empty Project," the grayed out "Precompiled header" check box remains checked unless you first uncheck it before checking "Empty project." This apparently requires you to create a precomplied header and include it in the C++ file.