Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of this error: "MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup"

Tags:

c++

lnk2019

I'm Helping a friend with her C++, but to be honest we need a big bit of help.

Why we always get this error: "MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup"

The Code is below:

 //Maria Delgado (1013725) - Coursework 2 - Program Conducting timber component structural design
#include<iostream>
#include<iomanip>
#include<cmath>
#include<fstream>
#include<string>
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<150)
        kH=pow(150/chosenDepth,0.2);
    else
        cout<<"Please input a depth less than 150mm"<<endl;
}

//Error message for all negative values entered
double errorNeg()
{
 float value=-1;
 while (value<0)
 {
  cout<<"You have entered a negative value. This variable cannot take negative values. Please input positive values!";
  cin>>value;
  cout<<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<<"The following dimensions need to be input into the program:"<<endl;

  cout<<"What is the desired beam LENGTH in millimeters?";
  cin>>chosenLength;
  if(chosenLength<0) chosenLength=errorNeg();

  cout<<"What is the desired beam WIDTH in millimeters?";
  cin>>chosenWidth;
  if(chosenWidth<0) chosenWidth=errorNeg();

  cout<<"What is the desired beam DEPTH in millimeters?";
  cin>>chosenDepth;
  if(chosenDepth<0) chosenDepth=errorNeg();

  cout<<"What is the desired beam BEARING LENGTH in millimeters?";
  cin>>chosenBearingLength;
  if(chosenBearingLength<0) chosenBearingLength = errorNeg();

  cout<<"Please insert a strength class of timber e.g.C12 to C50:";
  cin>>strengthClass;

  cout<<endl<<"Please choose a service class ability for member i.e. 1 or 2 or 3:";
  cin>>serviceClassAbility;

  cout<<endl;
 }


 //***************************CALCULATE OVERALL DESIGN LOAD************************************************************
 double load(beamMember designBeam)
 {
  cout<<"Under these circumstances, the beam will be adequate to support a slab."<<endl<<endl;
  double qK;
  double gK;
  double span;

  cout<<"Please input the total live load in kN/m2:";
  cin>>qK;
  cout<<endl;
  if (qK<0) qK=errorNeg();
  qK=qK*gammaQ;

  cout<<"Please input the total dead load in kN/m2:";
  cin>>gK;
  if (gK<0) gK=errorNeg();
  gK=gK*gammaG;

  cout<<"Enter the span between the beams in millimeters:";
  cin>>span;
  while(span<0) span=errorNeg();
  cout<<endl;
  span=span*(qK+gK)*chosenLength/10e2;
  cout<<"Point load:"<<span<<"N"<<endl<<endl;
  return span;
 }

 //***********************************CHECKING BENDING STRESS*********************************************************
 void checkBendingStress(beamMember designBeam, double force)
 {
  cout<<"Bending Stress Check:"<<endl;
  double bendingMoment;
  double secondMomentofArea;
  double designBendingStress;
  double actualBendingStress;

  bendingMoment=force*chosenLength/8;
  cout<<"Maximum bending moment is "<<bendingMoment<<"Nmm"<<endl;

  secondMomentofArea=chosenWidth*pow(chosenDepth,3)/12;

  designBendingStress=kH*kSYS*kMOD*matrix[0]/gammaM;
  actualBendingStress=(bendingMoment*chosenDepth/2)/secondMomentofArea;

  cout<<"Maximum permissibile stress:"<<designBendingStress<<"N/mm2"<<endl;
  cout<<"The actual stress that the beam is subject to:"<<actualBendingStress<<"N/mm2"<<endl;

  if(actualBendingStress<=designBendingStress)
   cout<<"Beam bending stress check successful!"<<endl<<endl;
  else
   cout<<"Beam bending stress check unnsuccessful!"<<endl<<endl;
 }

 //***********************************CHECKING SHEAR STRESS*********************************************************
 void checkShearStress(beamMember designBeam, double force)
 {
  cout<<"Shear Stress Check:"<<endl;
  double designShearingStress;
  double actualShearingStress;

  designShearingStress=matrix[5]*kMOD*kSYS/gammaM;
  actualShearingStress=(1.5*force/2)/(chosenWidth)/(chosenDepth);
  cout<<"Maximum permissible shear stress:"<<designShearingStress<<"N/mm2"<<endl;
  cout<<"Shear stress that the supports are subjected to:"<<actualShearingStress<<"N/mm2"<<endl;
  if(actualShearingStress<=designShearingStress)
   cout<<"Beam shear stress check successful!"<<endl<<endl;
  else
   cout<<"Beam shear stress check unsucessful!"<<endl<<endl;
 }

 //********************************CHECKING BEARING STRESS***********************************************************
 void checkBearingStress(beamMember designBeam, double force)
 {
  double kc90;
  double designBearingStress;
  double actualBearingStress;

  actualBearingStress=force/2/chosenWidth/chosenBearingLength;
  cout<<"Bearing Stress that the beam is subjected to:"<<actualBearingStress<<"N/mm2"<<endl;

  designBearingStress=matrix[4]*kMOD*kSYS/gammaM;
  cout<<"Maximum permissible bearing stress:"<<designBearingStress<<"N/mm2"<<endl;

  kc90=(2.38-chosenBearingLength/250)*(1+chosenDepth/12/chosenBearingLength);
  cout<<"Constant, kc90 is "<<kc90<<endl;
  cout<<"Factored design bearing stress is "<<kc90*designBearingStress<<endl;

  if (actualBearingStress<=designBearingStress)
   cout<<"Beam bearing stress check successful!"<<endl<<endl;
  else
   cout<<"Beam bearing stress check unsuccessful!"<<endl<<endl;
 }

 //********************************CHECKING LATERAL TORSIONAL STABILITY**************************************************
 void checkLateralTorsionalStability(beamMember designBeam, double force)
 {
  cout<<"Lateral Torsional Stability Check:"<<endl;

  double bendingMoment;
  double secondMomentofArea;
  double designBendingStress;
  double actualBendingStress;

  bendingMoment=force*chosenLength/8;
   cout<<"Maximum bending moment is "<<bendingMoment<<"Nmm"<<endl;

  secondMomentofArea=chosenWidth*pow(chosenDepth,3)/12;

  designBendingStress=kH*kSYS*kMOD*matrix[0]/gammaM;
  actualBendingStress=(bendingMoment*chosenDepth/2)/secondMomentofArea;

  cout<<"Maximum permissibile stress:"<<designBendingStress<<"N/mm2"<<endl;
  cout<<"The actual stress that the beam is subject to:"<<actualBendingStress<<"N/mm2"<<endl;

  if(actualBendingStress<=designBendingStress)
   cout<<"Beam Lateral Torsional Stability check successful!"<<endl<<endl;
  else
   cout<<"Beam Lateral Tosional Stability check unnsuccessful!"<<endl<<endl;
 }

 //*************************************FUNCTION FOR STRENGTH CLASS DATA FILE**********************************************
 void strengthClassData(string classStrength, double serviceClass)
 {
  string data;
  ifstream file;
  file.open("strengthclassdata.txt");
  file>>data;
  while(file&&data!=classStrength)
  {
   file>>data;
  }
  for(int i=0;i<=5;i++)
   file>>matrix[i];
  file.close();
 }

//Welcome Message for Program
void welcome()
{
 cout<<"The following is Yadhuvamshi Rajamani's program"<<endl
  <<"that conducts timber component structural design"<<endl
  <<"according to EC5. Specifically, it is a limit state"<<endl
  <<"design program that compares design actions with design strengths."<<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<<"Please select 1 to start the beam test program or 2 to exit the program, followed by enter!";
  cin>>startKey;
  cout<<endl;
  while(startKey!='2')
  {
   switch(startKey)
   {
   case '2':
    return 1;
   case '1':
    beamStartUp();
   break;
   }
  cout<<"Please select 1 to start the beam test program or 2 to exit the program, followed by enter!";
  cin>>startKey;
  cout<<endl;
  }
 return 1;
 }
};

`
like image 874
Stefani Botusharova Avatar asked Dec 16 '11 01:12

Stefani Botusharova


People also ask

What does unresolved external symbol mean?

Unresolved external references occur when the symbol for a function or global variable is referenced in a program, but none of the object files or libraries specified in the link step contain a definition for that symbol.


2 Answers

The int main() function needs to be outside your class definition. You'll want to create a class instance and use it to call the welcome and beamStartUp functions.

like image 55
Retired Ninja Avatar answered Sep 28 '22 17:09

Retired Ninja


I found a link that may help:

http://mihirknows.blogspot.com/2009/06/error-1-error-lnk2019-unresolved.html

like image 40
ksming Avatar answered Sep 28 '22 17:09

ksming