如何摆脱此错误:“MSVCRTD.lib(crtexe.obj):错误 LNK2019:函数 ___tmainCRTStartup 中引用了无法解析的外部符号 _main”

2024-02-22

我正在帮助一位朋友学习 C++,但说实话,我们需要大量帮助。

为什么我们总是收到此错误:“MSVCRTD.lib(crtexe.obj):错误 LNK2019:无法解析的外部 象征主要在函数 _ 中引用_tmainCRT启动”

代码如下:

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

`

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何摆脱此错误:“MSVCRTD.lib(crtexe.obj):错误 LNK2019:函数 ___tmainCRTStartup 中引用了无法解析的外部符号 _main” 的相关文章

  • 将集合绑定到自定义控件属性

    我没有运气尝试将数据集合绑定到我的自定义控件的属性 我已经实现了该控件的字符串属性的机制 在此处提供了一些帮助 并期望集合类型同样简单 但是我无法让它再次工作 这是我的自定义控件视图
  • 尚未注册类型“IServiceProviderFactory[Autofac.ContainerBuilder]”的服务

    当运行以下命令添加数据库迁移脚本时 出现以下错误 dotnet ef migrations add InitialCreate v o Migrations context MyContext 访问 Microsoft Extensions
  • QCombobox 向下箭头图像

    如何更改Qcombobox向下箭头图像 现在我正在使用这个 QSS 代码 但这不起作用 我无法删除向下箭头边框 QComboBox border 0px QComboBox down arrow border 0px background
  • 为什么在创建矩阵类时使用向量不好?

    对于我的矩阵类 我做了 template
  • 信号处理程序有单独的堆栈吗?

    信号处理程序是否有单独的堆栈 就像每个线程都有单独的堆栈一样 这是在 Linux C 环境中 来自 Linux 手册页signal 7 http kernel org doc man pages online pages man7 sign
  • 指向特征矩阵的指针数组

    我在代码中使用 Eigen 的 MatrixXd 矩阵 在某个时刻我需要一个 3D 矩阵 由于 Eigen 没有三维矩阵类型 因为它仅针对线性代数进行了优化 因此我创建了一个 MatrixXd 类型的指针数组 Eigen MatrixXd
  • GCC 和 ld 找不到导出的符号...但它们在那里

    我有一个 C 库和一个 C 应用程序 尝试使用从该库导出的函数和类 该库构建良好 应用程序可以编译 但无法链接 我得到的错误遵循以下形式 app source file cpp text 0x2fdb 对 lib namespace Get
  • ASP.Net Core 内容配置附件/内联

    我正在从 WebAPI 控制器返回一个文件 Content Disposition 标头值自动设置为 附件 例如 处置 附件 文件名 30956 pdf 文件名 UTF 8 30956 pdf 当它设置为附件时 浏览器将要求保存文件而不是打
  • 如何在 QTabWidget Qt 中展开选项卡

    我有一个QTabWidget像这个 但我想展开选项卡以 填充 整个小部件宽度 如下所示 我怎样才能做到这一点 我在用Qt 5 3 2 and Qt 创建者 3 2 1 Update 我尝试使用setExpanding功能 ui gt myT
  • 如何从文本文件读取整数到数组

    这就是我想做的 我对此有些不满 但我希望你能容忍我 这对我来说是一个非常新的概念 1 在我的程序中 我希望创建一个包含 50 个整数的数组来保存来自文件的数据 我的程序必须获取用户的文档文件夹的路径 2 文件的名称为 grades txt
  • C++ php 和静态库

    我创建了一个library a 其中包含 cpp 和 h 文件 其中包含很多类 嵌套类和方法 我想在 php 示例中包含这个静态库并尝试使用它 我想提一下 我是 php 新手 我已经在 test cpp 文件中测试了我的 libray a
  • 将二进制数据从 C# 上传到 PHP

    我想将文件从 Windows C 应用程序上传到运行 PHP 的 Web 服务器 我知道 WebClient UploadFile 方法 但我希望能够分块上传文件 以便我可以监控进度并能够暂停 恢复 因此 我正在读取文件的一部分并使用 We
  • .NET Core 中的跨平台文件名处理

    如何处理文件名System IO以跨平台方式运行类以使其在 Windows 和 Linux 上运行 例如 我编写的代码在 Windows 上完美运行 但它不会在 Ubuntu Linux 上创建文件 var tempFilename Dat
  • 使用restsharp序列化对象并将其传递给WebApi而不是序列化列表

    我有一个看起来像的视图模型 public class StoreItemViewModel public Guid ItemId get set public List
  • cout 和字符串连接

    我刚刚复习了我的 C 我尝试这样做 include
  • 更改 Windows Phone 系统托盘颜色

    有没有办法将 Windows Phone 上的系统托盘颜色从黑色更改为白色 我的应用程序有白色背景 所以我希望系统托盘也是白色的 您可以在页面 XAML 中执行此操作
  • 矩阵到数组 C#

    这将是转换方阵的最有效方法 例如 1 2 3 4 5 6 7 8 9 into 1 2 3 4 5 6 7 8 9 in c 我在做 int array2D new int 1 2 3 4 5 6 7 8 9 int array1D new
  • 将 char[][] 转换为 char** 会导致段错误吗?

    好吧 我的 C 有点生疏了 但我想我应该用 C 来做我的下一个 小 项目 这样我就可以对其进行抛光 并且我已经有不到 20 行的段错误了 这是我的完整代码 define ROWS 4 define COLS 4 char main map
  • QFileDialog::getSaveFileName 和默认的 selectedFilter

    我有 getSaveFileName 和一些过滤器 我希望当用户打开 保存 对话框时选择其中之一 Qt 文档说明如下 可以通过将 selectedFilter 设置为所需的值来选择默认过滤器 我尝试以下变体 QString selFilte
  • 从 JavaScript 中的 OnClientClick 事件中阻止 C# 中的 asp:Button OnClick 事件?

    我有一个asp Button在我的网页上 它调用 JavaScript 函数和代码隐藏方法 后者进行调用以导航到另一个页面 在 JavaScript 函数中 我正在检查条件 如果不满足这个条件 我想中止导航 以便OnClick方法未被调用

随机推荐