【问题标题】:LNK2019: unresolved external symbol C++ converting Fahrenheit to CelciusLNK2019:无法解析的外部符号 C++ 将华氏温度转换为摄氏度
【发布时间】:2015-12-21 11:12:39
【问题描述】:
#include <iostream>
#include <string>
using namespace std;

int main()
{
// declare variables
    string name; 
    float fahrenheit, celcius;
//display greeting
    cout << "Please enter your first name: ";
    cin >> name;
//ask for fahrenheit
    cout << "Enter a temperature in Fahrenheit degrees please: ";
    cin >> fahrenheit;
//write equation
    celcius = 5.0f/9.0f * (fahrenheit - 32.0f);
//display result
    cout << "Hi " << name << endl << endl;
    cout << "The equivalent to " << fahrenheit << "degrees Fahrenheit is" << celcius << "degrees Celcius" << endl << endl;

return 0;
}

我不确定到底是什么不正确我已经检查了很多次并使用代码来消除错误无济于事。任何帮助表示赞赏。

【问题讨论】:

  • 具体的错误信息是什么?
  • 1>MSVCRTD.lib(crtexew.obj):错误 LNK2019:未解析的外部符号 _WinMain@16 在函数 ___tmainCRTStartup 1>C:\Users\Nora\Documents\Visual Studio 2008\Projects\Project1 中引用\lab2T13\Debug\lab2T13.exe : 致命错误 LNK1120: 1 unresolved externals
  • 我觉得你需要把项目配置成控制台项目(不是win32应用)
  • 我按照教授的指示使用的是win32,所以没有改变
  • 和你教授谈谈。

标签: c++ unresolved-external


【解决方案1】:

作为给你的解释

您输入的代码完全正确。它编译干净。但是,为完成制作正在运行的应用程序(“链接”)的过程而进行的设置方式失败了。

链接器期望找到一个名为 _WinMain 的入口点(因此出现错误消息)。这是因为当您创建项目时,您说它是一个 Windows 应用程序 - 它不是。你需要问你教授

另外 - 当问到“为什么我会收到这个错误?”始终在问题中包含错误

【讨论】:

  • 哇,我觉得自己很笨,但是当没有看到任何错误时,幸福胜过一切,非常感谢,对不起,我是菜鸟。
  • 我们曾经都是菜鸟
【解决方案2】:

int main() 更改为:

int _tmain(int argc, _TCHAR* argv[])

这里有一个Hello World sample program 可以查看。

【讨论】:

  • @Nora:在这种情况下,请改用wchar_t*
猜你喜欢
  • 1970-01-01
  • 2016-02-08
  • 1970-01-01
  • 1970-01-01
  • 2021-10-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多