【问题标题】:Yet another LNK2019: unresolved external symbol又一个 LNK2019:未解析的外部符号
【发布时间】:2012-02-25 18:59:09
【问题描述】:

我正在为一个学校项目创建主干,但我遇到了“未解决的外部符号”错误。根据该站点上提到的先前问题,我认为必须手动将我的项目链接到 .lib 文件。问题是,我不知道我需要链接到哪个 .lib。有人能解释一下我十二岁吗?

1>------ Build started: Project: Birthday311, Configuration: Debug Win32 ------
1>Build started 2/2/2012 07:55:30 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\Birthday311.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>birthday_test.obj : error LNK2019: unresolved external symbol "public: int __thiscall Birthday::getDay(void)const " (?getDay@Birthday@@QBEHXZ) referenced in function "void __cdecl test_class_Birthday_default_ctor(class Tester &)" (?test_class_Birthday_default_ctor@@YAXAAVTester@@@Z)
1>birthday_test.obj : error LNK2019: unresolved external symbol "public: int __thiscall Birthday::getMonth(void)const " (?getMonth@Birthday@@QBEHXZ) referenced in function "void __cdecl test_class_Birthday_default_ctor(class Tester &)" (?test_class_Birthday_default_ctor@@YAXAAVTester@@@Z)
1>birthday_test.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Birthday::getName(void)const " (?getName@Birthday@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "void __cdecl test_class_Birthday_default_ctor(class Tester &)" (?test_class_Birthday_default_ctor@@YAXAAVTester@@@Z)
1>C:\Users\Ender\Documents\Visual Studio 2010\Projects\Birthday311\Debug\Birthday311.exe : fatal error LNK1120: 3 unresolved externals

【问题讨论】:

  • 应该如何我们知道哪个.lib文件?哪一个包含Birthday::getDayBirthday::getMonth 函数的定义?这些不是我所知道的任何标准库的一部分,因此您必须自己编写它们。
  • 哦,你帮我找出了正确的答案。查看我的 .cpp 文件,我意识到我只是将 getDay 和 getMonth 函数称为 int getDay() 而不是 int Birthday::getDay() const。谢谢!

标签: unresolved-external lnk2019


【解决方案1】:

看来您实际上并没有实现函数 getDay、getMonth 和 getName。

【讨论】:

  • 哦,你帮我找出了正确的答案。查看我的 .cpp 文件,我意识到我只是将 getDay 和 getMonth 函数称为“int getDay()”而不是“int Birthday::getDay() const”。基本上,我没有正确实现 getDay 和 getMonth 函数。谢谢!
猜你喜欢
  • 2014-11-07
  • 2013-06-01
  • 1970-01-01
  • 2022-01-06
  • 2014-09-19
  • 2012-12-17
  • 1970-01-01
  • 1970-01-01
  • 2019-05-27
相关资源
最近更新 更多