c++ - 错误 LMK2019 : unresolved symbol/fatal error LNK1120: 1 unresolved externals

标签 c++ visual-studio

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

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文件中写的代码:

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

}

任何人都可以阐明我做错了什么吗?

最佳答案

自从我编写 Windows 应用程序以来已有很长时间了,但这感觉就像您正在创建 Windows 应用程序而不是控制台应用程序,因此您的代码中应该有一个 WinMain ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms633559%28v=vs.85%29.aspx)...

关于c++ - 错误 LMK2019 : unresolved symbol/fatal error LNK1120: 1 unresolved externals,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22156652/

相关文章:

visual-studio - Microsoft Visual Studio 2012 已停止工作

visual-studio - 如何防止Visual Studio或Docker更改主机端口号?

visual-studio - 发布到 Azure 不会更新 App_Data 中的文件

c# - Visual Studio Xamarin : Could not connect to the debugger

c++ - 将硬盘驱动器上的 BIT XXX 从 0 更改为 1

xml - Azure部署: error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace

c++ - 这个无操作 while 循环用于断言宏的原因是什么?

C++ UDP客户端问题

C++重载函数问题

c++ - 打印给定字符串的 50% 或一半