gpt4 book ai didi

c++ - 如何摆脱这个错误 : "MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup"

转载 作者:可可西里 更新时间:2023-11-01 17:32:54 28 4
gpt4 key购买 nike

我正在帮助一位 friend 学习 C++,但老实说,我们需要很大的帮助。

为什么我们总是得到这个错误:“MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external符号 main 在函数 __tmainCRTStartup 中引用”

代码如下:

 //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;
}
};

`

最佳答案

int main() 函数需要在您的类定义之外。您需要创建一个类实例并使用它来调用 welcome 和 beamStartUp 函数。

关于c++ - 如何摆脱这个错误 : "MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8528863/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com