简体   繁体   English

虚幻引擎中的链接错误

[英]Link Error in Unreal Engine

Disclaimer: there is a high chance this is very specific to Unreal Engine, but I haven't got an answer there so I thought I'd try a more general query here. 免责声明:很有可能这是虚幻引擎特有的,但是我在那里没有答案,所以我想在这里尝试更一般的查询。 Sorry if this is considered off topic/too specific 抱歉,如果这被认为不在主题范围内/过于具体

I am getting a link error compiling the following code in Unreal Engine 4: 我在虚幻引擎4中编译以下代码时遇到链接错误:

RHISetRenderTarget(TextureRenderTarget->GetRenderTargetTexture(), NULL);

This is being called within a macro ( ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER ) but the link error happens even if you don't. 这是在宏( ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER )中调用的,但是即使没有,也会发生链接错误。

The error itself is: 错误本身是:

MaterialToTextureRenderer.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl RHISetRenderTargets(unsigned int,class FRHIRenderTargetView const *,class FRHITexture *,unsigned int,class FRHIUnorderedAccessView * const *)" (__imp_?RHISetRenderTargets@@YAXIPEBVFRHIRenderTargetView@@PEAVFRHITexture@@IPEBQEAVFRHIUnorderedAccessView@@@Z) referenced in function "void __cdecl RHISetRenderTarget(class FRHITexture *,class FRHITexture *)" (?RHISetRenderTarget@@YAXPEAVFRHITexture@@0@Z)

Compressed for readability: 压缩以提高可读性:

unresolved external symbol: void RHISetRenderTargets(unsigned int, FRHIRenderTargetView const *,FRHITexture *,unsigned int,FRHIUnorderedAccessView * const *)
referenced in: void RHISetRenderTarget(FRHITexture *,FRHITexture *)

(The method the unlinked method is referenced in is the method I am calling). (未链接的方法所引用的方法是我正在调用的方法)。

And 4 other simillar link errors. 以及其他4个类似链接错误。

I'm not by any stretch of the imagination a C++ expert, but my understanding is a link error is caused when the header file is correctly included but then it can't actual find an implementation of the method to point to. 我并没有想像C ++专家,但是我的理解是,当正确包含头文件但实际上找不到该方法的实现时,就会导致链接错误。

What I don't understand is, the method whose implementation it can't find, is within the Unreal Engine (which I am assuming doesn't actually have missing method implementations etc!). 我不明白的是,它的实现找不到的方法位于虚幻引擎中(我假设它实际上并没有缺少方法实现等!)。

Further, both the method I am calling, and the method it is calling (and can't link) are both defined inline in the same header file. 此外,我正在调用的方法和它正在调用的方法(无法链接)都在同一头文件中inline定义。 The only thing I can see that could be wrong is the method that is being used is declared and implemented further down the header file, but I don't believe that could be a problem (certainly not a link problem). 我唯一看到的可能是错误的是,正在使用的方法是在标头文件中声明和实现的,但是我不认为这可能是个问题(当然不是链接问题)。

确保在.build.cs中为这样的目标包含RHI和RenderCore

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RHI", "RenderCore", "ShaderCore" });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM