C++ 未解析的外部

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7004031/
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-28 16:19:30  来源:igfitidea点击:

C++ unresolved externals

c++c

提问by Sublimemm

Does anyone know what this means?

有谁知道这是什么意思?

1>  Generating Code...
1>BlankWindowDXbaseImpl.obj : error LNK2019: unresolved external symbol "public: __thiscall DXBase::DXBase(void)" (??0DXBase@@QAE@XZ) referenced in function "public: __thiscall BlankWindowDXBaseImpl::BlankWindowDXBaseImpl(void)" (??0BlankWindowDXBaseImpl@@QAE@XZ)
1>BlankWindowDXbaseImpl.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall DXBase::~DXBase(void)" (??1DXBase@@UAE@XZ) referenced in function "public: virtual __thiscall BlankWindowDXBaseImpl::~BlankWindowDXBaseImpl(void)" (??1BlankWindowDXBaseImpl@@UAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall DXBase::shutdown(void)" (?shutdown@DXBase@@QAEXXZ) referenced in function _wWinMain@16
1>main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall DXBase::initalize(struct HINSTANCE__ *,struct HWND__ *)" (?initalize@DXBase@@QAE_NPAUHINSTANCE__@@PAUHWND__@@@Z) referenced in function _wWinMain@16
1>C:\backup\development\directXworkspace\BlankWindow\Debug\BlankWindow.exe : fatal error LNK1120: 4 unresolved externals

回答by Vinicius Kamakura

It means that you have unresolved external symbols.

这意味着您有未解析的外部符号。

What are symbols?Symbols can be anything from variables, classes, member functions or functions.

什么是符号?符号可以是变量、类、成员函数或函数中的任何东西。

Why they are unresolved?Some part of your code (or libraries that you are using) rely on these symbols and they are not being found because you are not linking the correct library or implementing them.

为什么他们没有解决?您的代码(或您正在使用的库)的某些部分依赖于这些符号,并且由于您没有链接正确的库或未实现它们而无法找到它们。

回答by Ben Voigt

Yes, it means your program calls functions that are declared but have no body.

是的,这意味着您的程序调用已声明但没有主体的函数。

Are you expecting these functions to be part of your code, or provided by some library?

您希望这些函数成为您代码的一部分,还是由某个库提供?

回答by ccozad

It means you have a linker problem. (The linker can't find a library with those symbols) You need to include the required library in your library path.

这意味着您有链接器问题。(链接器找不到包含这些符号的库)您需要在库路径中包含所需的库。

回答by A. K.

probably you are not linking against proper library.

可能您没有链接到正确的库。

But you should give some more details.. it looks like you are asking question in a quiz contest.

但是你应该提供更多细节......看起来你是在问答比赛中提问。

回答by TPCoder

I just had the same issue and if you add the #pragma comment(lib,"d3d9.lib") This will include the library files necessary to compile your code. It is just getting confused which lib file to grab either the 64 or 32 bit. Hope this helps.

我刚刚遇到了同样的问题,如果您添加 #pragma comment(lib,"d3d9.lib") 这将包括编译代码所需的库文件。只是对获取 64 位或 32 位的 lib 文件感到困惑。希望这可以帮助。

回答by Malick

I'm sharing a just faced issue that was difficult to detect: if you are linking to two libs (a.liband b.lib) located in different lib paths ( /PathToA/and /PathToB/), the problem of unresolved externals may arise if there is an old version of, let's say b.libin the path /PathToA/.

我分享一个公正面临的问题,这是很难检测:如果您链接两个库(a.libb.lib)位于不同的LIB路径(/PathToA//PathToB/),如果有老版本的可能出现无法解析外部的问题,比方说, b.lib在路径中/PathToA/

In this case, you may incorrectly link to an unwanted lib. So as a solution for this particular multi-linking problem, be sure that you do not have several versions of a library in your library paths.

在这种情况下,您可能会错误地链接到不需要的库。因此,作为此特定多链接问题的解决方案,请确保您的库路径中没有多个版本的库。