Long time since I wrote a windows app, but this feels like you are creating a Windows application instead a console application, thus you should have a WinMain (http://msdn.microsoft.com/en-us/library/windows/desktop/ms633559%28v=vs.85%29.aspx) in your code somewhere...
error LMK2019: unresolved symbol / fatal error LNK1120: 1 unresolved externals
-
19-10-2022 - |
Вопрос
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 ==========
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;
}
Can anyone shed some light on what I am doing wrong?
Нет правильного решения
Другие советы
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.
Не связан с StackOverflow