本文介绍了错误LMK2019:未解决的符号/致命错误LNK1120:1未解析的外部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试构建时收到以下错误:

I am receiving the following error when I attempt to build:

1> MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1> G:\CMPSC 101\Projects\Project 2\Project2\Debug\Project2.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

这里是我在cpp文件中编写的代码:

Here the code that I have written in the cpp file:

// Source file name: Project2.cpp
// This program determines a user's target heart rate and body mass index
// when the user's age, height, and weight are input

// Date written: 27 Feb 2014
// Date modified: 3 Mar 2014

#include <iostream>
using std::cout;
using std::endl;
#include <iostream>
using namespace std;

int main()
{

//age is the input variable from user, target_heart_rate is output after calculation
int age, target_heart_rate;
int weight;
int height, bmi;

//Display Program Introduction and Credits
cout << "Happy Valley Health Club" << endl;
cout << "Target Heart Rate Calculator" << endl;
cout << "Written by Paul D. Wagaman" << endl;

//Display Target Heart Rate Formula
cout << "Your Target Heart Rate is 70% of (220 - your age)" << endl;

//Prompt User to enter their age as a whole number
cout << "Please enter your age as a whole number" << endl;

//User inputs their age
cin >> age;

//Display Body Mass Index Formula
cout << "BMI (kg/m2) = [Weight (lbs) x 703] / Height (in2)" << endl;

//Prompt User to enter their age as a whole number
cout << "Please enter your weight (in pounds) as a whole number" << endl;

//User inputs their age
cin >> weight;

//Prompt User to enter their age as a whole number
cout << "Please enter your height (in inches) as a whole number" << endl;

//User inputs their age
cin >> height;

//Perform target heart rate calculation
//70%  of  ( 220 - age )
target_heart_rate = ((70 * (220-age))/100);

//Perform BMI calculation
//70%  of  ( 220 - age )
bmi = (weight * 703) / (height * height);

//Display user’s target heart rate
cout << "70%" << " ( " << "220" << " - " << age << " ) " << " = " << target_heart_rate << endl;
cout << "Your target heart rate is " << target_heart_rate << " beats per minute." << endl;

//Display user’s body mass index
cout << "Your BMI formula = (" << weight << "pounds" << " x " << "703)" << " / " << " ( " << height << " squared." << endl;
cout << "Your individual Body Mass Index is " << bmi << endl;

//Display "Thank You" message
cout << "Thank you for choosing Happy Valley Health Club – We care about YOUR health!";

return 0;

}

任何人都可以

推荐答案

似乎你选择了错误的项目类型WinMain可以在Windows程序中找到,但是你显示的代码是一个控制台应用程序如果你在Visual Studio中这样做,你可能需要重新创建一个控制台应用程序,而不是Windows应用程序。

It seems like you have selected the wrong project type. WinMain can be found in Windows programs, but the code you show is for a console application. If you did this in Visual Studio, you may have to recreate your project as a console application, not a Windows application.

这篇关于错误LMK2019:未解决的符号/致命错误LNK1120:1未解析的外部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 23:46