Visual C 致命错误 LNK1120:1 个未解析的外部

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15489597/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 19:25:45  来源:igfitidea点击:

Visual C fatal error LNK1120: 1 unresolved externals

c++

提问by user2035780

Don't know whats wrong, all help will be greatly appreciated. I'm thinking I am having a problem with a file source, but am not sure.

不知道出了什么问题,所有帮助将不胜感激。我想我的文件源有问题,但我不确定。

1>------ Build started: Project: Assignment 08 ADL, Configuration: Debug Win32 ------
1>Build started 3/18/2013 8:37:38 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\Assignment 08 ADL.unsuccessfulbuild".
1>ClCompile:
1>  Assignment 08 ADL.cpp
1>  Generating Code...
1>  Skipping... (no relevant changes detected)
1>  student.cpp
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>Assignment 08 ADL.obj : error LNK2019: unresolved external symbol "long __cdecl    decimals(class std::basic_ostream<char,struct std::char_traits<char> > &,int)" (? decimals@@YAJAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z) referenced in function "void __cdecl display(class student)" (?display@@YAXVstudent@@@Z)
1>J:\CO 127\Assignment 08 ADL\Debug\Assignment 08 ADL.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:24.82

采纳答案by shf301

You need to look at the line above LNK1120, the LNK2019error tells you what is wrong.

您需要查看上面的行LNK1120LNK2019错误告诉您出了什么问题。

Inside of your void display(class student)function you are calling a function named decimalsthat is not defined anywhere in your source code or in a library.

在您的void display(class student)函数内部,您正在调用一个decimals未在源代码或库中的任何位置定义的函数。

回答by Mohamed El Shenawy

This problem appeared to me when I added .c file instead of .cpp so check the name of the files as well

当我添加 .c 文件而不是 .cpp 时,这个问题出现在我身上,所以还要检查文件的名称

回答by Khan

Make sure the external variable able to access in your current file. For Testingeasy way is declare same name local variable for testing your logic working not , later change try to access external variable.

确保外部变量能够在当前文件中访问。 对于测试简单的方法是声明同名局部变量来测试你的逻辑是否正常工作,稍后更改尝试访问外部变量。

回答by Maverick

LNK 2019 error is a linker error which generally means some object is not available to the linker. Try clean rebuilding the project and then try to execute it.

LNK 2019 错误是链接器错误,这通常意味着链接器无法使用某些对象。尝试干净地重建项目,然后尝试执行它。