title: How to get rid of this error: "MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup"
body: <p>I'm Helping a friend with her C++, but to be honest we need a big bit of help.</p>
  
  <p>Why we always get this error: "MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external 
  symbol <em>main referenced in function _</em>_tmainCRTStartup" </p>
  
  <p>The Code is below:</p>
  
  <pre><code> //Maria Delgado (1013725) - Coursework 2 - Program Conducting timber component structural design
  #include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  #include&lt;cmath&gt;
  #include&lt;fstream&gt;
  #include&lt;string&gt;
  using namespace std;
  //Variables for Strength Properties in (N/mm2)
  //fmk=Bending
  //fc90k=Compression Perpendicular
  //fvk=Shear
  
  //Calculating Member Size Factor:
  void memberSizeFactor(double chosenDepth)
  {
      if (chosenDepth&lt;150)
          kH=pow(150/chosenDepth,0.2);
      else
          cout&lt;&lt;"Please input a depth less than 150mm"&lt;&lt;endl;
  }
  
  //Error message for all negative values entered
  double errorNeg()
  {
   float value=-1;
   while (value&lt;0)
   {
    cout&lt;&lt;"You have entered a negative value. This variable cannot take negative values. Please input positive values!";
    cin&gt;&gt;value;
    cout&lt;&lt;endl;
   }
   return value;
  }
  
  //Beam Member Class
  class beamMember
  {
  private:
   double chosenLength;
   double chosenWidth;
   double chosenDepth;
   double chosenBearingLength;
   double serviceClassAbility;
   string strengthClass;
  public:
   beamMember()
   {
    chosenLength=chosenWidth=chosenDepth=chosenBearingLength=serviceClassAbility=0;
  
    strengthClass="";
   }
  
   void beamDimensionsData()
   {
    cout&lt;&lt;"The following dimensions need to be input into the program:"&lt;&lt;endl;
  
    cout&lt;&lt;"What is the desired beam LENGTH in millimeters?";
    cin&gt;&gt;chosenLength;
    if(chosenLength&lt;0) chosenLength=errorNeg();
  
    cout&lt;&lt;"What is the desired beam WIDTH in millimeters?";
    cin&gt;&gt;chosenWidth;
    if(chosenWidth&lt;0) chosenWidth=errorNeg();
  
    cout&lt;&lt;"What is the desired beam DEPTH in millimeters?";
    cin&gt;&gt;chosenDepth;
    if(chosenDepth&lt;0) chosenDepth=errorNeg();
  
    cout&lt;&lt;"What is the desired beam BEARING LENGTH in millimeters?";
    cin&gt;&gt;chosenBearingLength;
    if(chosenBearingLength&lt;0) chosenBearingLength = errorNeg();
  
    cout&lt;&lt;"Please insert a strength class of timber e.g.C12 to C50:";
    cin&gt;&gt;strengthClass;
  
    cout&lt;&lt;endl&lt;&lt;"Please choose a service class ability for member i.e. 1 or 2 or 3:";
    cin&gt;&gt;serviceClassAbility;
  
    cout&lt;&lt;endl;
   }
  
  
   //***************************CALCULATE OVERALL DESIGN LOAD************************************************************
   double load(beamMember designBeam)
   {
    cout&lt;&lt;"Under these circumstances, the beam will be adequate to support a slab."&lt;&lt;endl&lt;&lt;endl;
    double qK;
    double gK;
    double span;
  
    cout&lt;&lt;"Please input the total live load in kN/m2:";
    cin&gt;&gt;qK;
    cout&lt;&lt;endl;
    if (qK&lt;0) qK=errorNeg();
    qK=qK*gammaQ;
  
    cout&lt;&lt;"Please input the total dead load in kN/m2:";
    cin&gt;&gt;gK;
    if (gK&lt;0) gK=errorNeg();
    gK=gK*gammaG;
  
    cout&lt;&lt;"Enter the span between the beams in millimeters:";
    cin&gt;&gt;span;
    while(span&lt;0) span=errorNeg();
    cout&lt;&lt;endl;
    span=span*(qK+gK)*chosenLength/10e2;
    cout&lt;&lt;"Point load:"&lt;&lt;span&lt;&lt;"N"&lt;&lt;endl&lt;&lt;endl;
    return span;
   }
  
   //***********************************CHECKING BENDING STRESS*********************************************************
   void checkBendingStress(beamMember designBeam, double force)
   {
    cout&lt;&lt;"Bending Stress Check:"&lt;&lt;endl;
    double bendingMoment;
    double secondMomentofArea;
    double designBendingStress;
    double actualBendingStress;
  
    bendingMoment=force*chosenLength/8;
    cout&lt;&lt;"Maximum bending moment is "&lt;&lt;bendingMoment&lt;&lt;"Nmm"&lt;&lt;endl;
  
    secondMomentofArea=chosenWidth*pow(chosenDepth,3)/12;
  
    designBendingStress=kH*kSYS*kMOD*matrix[0]/gammaM;
    actualBendingStress=(bendingMoment*chosenDepth/2)/secondMomentofArea;
  
    cout&lt;&lt;"Maximum permissibile stress:"&lt;&lt;designBendingStress&lt;&lt;"N/mm2"&lt;&lt;endl;
    cout&lt;&lt;"The actual stress that the beam is subject to:"&lt;&lt;actualBendingStress&lt;&lt;"N/mm2"&lt;&lt;endl;
  
    if(actualBendingStress&lt;=designBendingStress)
     cout&lt;&lt;"Beam bending stress check successful!"&lt;&lt;endl&lt;&lt;endl;
    else
     cout&lt;&lt;"Beam bending stress check unnsuccessful!"&lt;&lt;endl&lt;&lt;endl;
   }
  
   //***********************************CHECKING SHEAR STRESS*********************************************************
   void checkShearStress(beamMember designBeam, double force)
   {
    cout&lt;&lt;"Shear Stress Check:"&lt;&lt;endl;
    double designShearingStress;
    double actualShearingStress;
  
    designShearingStress=matrix[5]*kMOD*kSYS/gammaM;
    actualShearingStress=(1.5*force/2)/(chosenWidth)/(chosenDepth);
    cout&lt;&lt;"Maximum permissible shear stress:"&lt;&lt;designShearingStress&lt;&lt;"N/mm2"&lt;&lt;endl;
    cout&lt;&lt;"Shear stress that the supports are subjected to:"&lt;&lt;actualShearingStress&lt;&lt;"N/mm2"&lt;&lt;endl;
    if(actualShearingStress&lt;=designShearingStress)
     cout&lt;&lt;"Beam shear stress check successful!"&lt;&lt;endl&lt;&lt;endl;
    else
     cout&lt;&lt;"Beam shear stress check unsucessful!"&lt;&lt;endl&lt;&lt;endl;
   }
  
   //********************************CHECKING BEARING STRESS***********************************************************
   void checkBearingStress(beamMember designBeam, double force)
   {
    double kc90;
    double designBearingStress;
    double actualBearingStress;
  
    actualBearingStress=force/2/chosenWidth/chosenBearingLength;
    cout&lt;&lt;"Bearing Stress that the beam is subjected to:"&lt;&lt;actualBearingStress&lt;&lt;"N/mm2"&lt;&lt;endl;
  
    designBearingStress=matrix[4]*kMOD*kSYS/gammaM;
    cout&lt;&lt;"Maximum permissible bearing stress:"&lt;&lt;designBearingStress&lt;&lt;"N/mm2"&lt;&lt;endl;
  
    kc90=(2.38-chosenBearingLength/250)*(1+chosenDepth/12/chosenBearingLength);
    cout&lt;&lt;"Constant, kc90 is "&lt;&lt;kc90&lt;&lt;endl;
    cout&lt;&lt;"Factored design bearing stress is "&lt;&lt;kc90*designBearingStress&lt;&lt;endl;
  
    if (actualBearingStress&lt;=designBearingStress)
     cout&lt;&lt;"Beam bearing stress check successful!"&lt;&lt;endl&lt;&lt;endl;
    else
     cout&lt;&lt;"Beam bearing stress check unsuccessful!"&lt;&lt;endl&lt;&lt;endl;
   }
  
   //********************************CHECKING LATERAL TORSIONAL STABILITY**************************************************
   void checkLateralTorsionalStability(beamMember designBeam, double force)
   {
    cout&lt;&lt;"Lateral Torsional Stability Check:"&lt;&lt;endl;
  
    double bendingMoment;
    double secondMomentofArea;
    double designBendingStress;
    double actualBendingStress;
  
    bendingMoment=force*chosenLength/8;
     cout&lt;&lt;"Maximum bending moment is "&lt;&lt;bendingMoment&lt;&lt;"Nmm"&lt;&lt;endl;
  
    secondMomentofArea=chosenWidth*pow(chosenDepth,3)/12;
  
    designBendingStress=kH*kSYS*kMOD*matrix[0]/gammaM;
    actualBendingStress=(bendingMoment*chosenDepth/2)/secondMomentofArea;
  
    cout&lt;&lt;"Maximum permissibile stress:"&lt;&lt;designBendingStress&lt;&lt;"N/mm2"&lt;&lt;endl;
    cout&lt;&lt;"The actual stress that the beam is subject to:"&lt;&lt;actualBendingStress&lt;&lt;"N/mm2"&lt;&lt;endl;
  
    if(actualBendingStress&lt;=designBendingStress)
     cout&lt;&lt;"Beam Lateral Torsional Stability check successful!"&lt;&lt;endl&lt;&lt;endl;
    else
     cout&lt;&lt;"Beam Lateral Tosional Stability check unnsuccessful!"&lt;&lt;endl&lt;&lt;endl;
   }
  
   //*************************************FUNCTION FOR STRENGTH CLASS DATA FILE**********************************************
   void strengthClassData(string classStrength, double serviceClass)
   {
    string data;
    ifstream file;
    file.open("strengthclassdata.txt");
    file&gt;&gt;data;
    while(file&amp;&amp;data!=classStrength)
    {
     file&gt;&gt;data;
    }
    for(int i=0;i&lt;=5;i++)
     file&gt;&gt;matrix[i];
    file.close();
   }
  
  //Welcome Message for Program
  void welcome()
  {
   cout&lt;&lt;"The following is Yadhuvamshi Rajamani's program"&lt;&lt;endl
    &lt;&lt;"that conducts timber component structural design"&lt;&lt;endl
    &lt;&lt;"according to EC5. Specifically, it is a limit state"&lt;&lt;endl
    &lt;&lt;"design program that compares design actions with design strengths."&lt;&lt;endl;
  }
  
   //******************************BEAM START UP*****************************************************************************
   void beamStartUp()
   {
    beamMember designBeam;
    double force;
    designBeam.beamDimensionsData();
    force=load(designBeam);
    checkBendingStress(designBeam,force);
    checkShearStress(designBeam,force);
    checkBearingStress(designBeam,force);
    checkLateralTorsionalStability(designBeam,force);
   }
  
   int main()
   {
    welcome();
    char startKey;
    cout&lt;&lt;"Please select 1 to start the beam test program or 2 to exit the program, followed by enter!";
    cin&gt;&gt;startKey;
    cout&lt;&lt;endl;
    while(startKey!='2')
    {
     switch(startKey)
     {
     case '2':
      return 1;
     case '1':
      beamStartUp();
     break;
     }
    cout&lt;&lt;"Please select 1 to start the beam test program or 2 to exit the program, followed by enter!";
    cin&gt;&gt;startKey;
    cout&lt;&lt;endl;
    }
   return 1;
   }
  };
  
  `
  </code></pre>