Linking error installing plugin packaged with Unreal (possible bug?)

 

Hello,

We've been trying hard to install an Unreal plugin built by ourselves into Aximmetry, but we've been having lots of problems with the compiler failing to link it correctly using Unreal for Aximmetry, even though in Epic's Unreal Engine the plugin could be built without any problems and it's working.

Here's an example of the first two lines of the LNK errors, it's in Spanish but they are the usual LNK2019 Unresolved External Symbol messages by MSVC:

LogAximmetry: Display: UnrealBuildTool: Module.BPImportDLL.cpp.obj : error LNK2019: s?mbolo externo "__declspec(dllimport) class UPackage * __cdecl GetTransientPackage(void)" (__imp_?GetTransientPackage@@YAPEAVUPackage@@XZ) sin resolver al que se hace referencia en la funci?n "public: static class UObject * __cdecl AActor2DLL::__VTableCtorCaller(class FVTableHelper &)" (?__VTableCtorCaller@AActor2DLL@@SAPEAVUObject@@AEAVFVTableHelper@@@Z)

LogAximmetry: Display: UnrealBuildTool: Module.BPImportDLL.cpp.obj : error LNK2019: s?mbolo externo "__declspec(dllimport) class UObject * __cdecl StaticAllocateObject(class UClass const *,class UObject *,class FName,enum EObjectFlags,enum EInternalObjectFlags,bool,bool *,class UPackage *)" (__imp_?StaticAllocateObject@@YAPEAVUObject@@PEBVUClass@@PEAV1@VFName@@W4EObjectFlags@@W4EInternalObjectFlags@@_NPEA_NPEAVUPackage@@@Z) sin resolver al que se hace referencia en la funci?n "public: static void * __cdecl AActor2DLL::operator new(unsigned __int64,enum EInternal,class UObject *,class FName,enu

m EObjectFlags)" (??2AActor2DLL@@SAPEAX_KW4EInternal@@PEAVUObject@@VFName@@W4EObjectFlags@@@Z)

We've traced the problem to be in a setting defined in "UnrealGamePlugin.Target.cs" (Aximmetry DE/UnrealEngine/Engine/). If we comment the line "LinkType = TargetLinkType.Modular;", the plugin links and works without any problem, as it would do in Unreal.

What is the root of this problem? Is it something in the machine this is being worked on? Do we need to change anything in our end? We would prefer to leave Aximmetry settings as default so we don't have to document and replicate the changes for every machine working with Aximmetry.

Cheers

   HerrLorenzo

 
Profile Image
Eifert@Aximmetry
  -  

Hi,

You need to build in Modular otherwise no plugin DLLs will be created. These DLLs are loaded when using Aximmetry in cooked mode.

Linker errors are usually caused by missing dependencies in the plugin's Build.cs file.

In your case, the GetTransientPackage function is not found by the linker. You can find this function in the CoreUObject module's code.
So you need to add the CoreUObject as a dependency in your BPImportDLL.Build.cs file by adding the following line:
PrivateDependencyModuleNames.Add("CoreUObject");

After this, we think your plugin should build without a problem.

Warmest regards,

 
Profile Image
HerrLorenzo
  -  

Thank you Eifert! Unfortunately, that solution isn't working.

After reverting the change so it's building in Modular again, I'm getting these two errors (only these two, then it fails building the plugin). Again, errors are in Spanish so for reference, they are the standard LNK2019 and LNK1120.

We've checked and UE::Math::TVector<double> is part of the "Core" Unreal Engine module, which is added correctly in the build settings. I'm getting out of ideas about what might be happening.

The plugin is compiling well in Epic's Unreal Engine, and the only way for it to show the same LNK errors as in Aximmetry's UE are by deleting "Core" from the PluginCompile.Build.cs file.


[9/11] Link UnrealGame-BPImportDLL.dll

LogAximmetry: Display: UnrealBuildTool:    Creating library ..\Plugins\Marketplace\BPImportDLL\Intermediate\Build\Win64\UnrealGame\Development\BPImportDLL\UnrealGame-BPImportDLL.suppressed.lib y objeto ..\Plugins\Marketplace\BPImportDLL\Intermediate\Build\Win64\UnrealGame\Development\BPImportDLL\UnrealGame-BPImportDLL.suppressed.exp

LogAximmetry: Display: UnrealBuildTool: SharedPCH.Engine.ShadowErrors.h.obj : error LNK2019: s?mbolo externo "public: static struct UE::Math::TVector<double> const UE::Math::TVector<double>::ZeroVector" (?ZeroVector@?$TVector@N@Math@UE@@2U123@B) sin resolver al que se hace referencia en la funci?n "void __cdecl FNavigationSystem::`dynamic initializer for 'InvalidBoundingBox''(void)" (??__EInvalidBoundingBox@FNavigationSystem@@YAXXZ)

LogAximmetry: Display: UnrealBuildTool: Module.BPImportDLL.cpp.obj : error LNK2011: objeto precompilado no vinculado; quiz? la imagen no se pueda ejecutar

LogAximmetry: Display: UnrealBuildTool:   Sugerencia sobre los s?mbolos definidos que podr?an coincidir:

LogAximmetry: Display: UnrealBuildTool:     __@@_PchSym_@00@UyfrowUQQfvFUhbmxUvmtrmvUrmgvinvwrzgvUyfrowUdrmGEUfmivzotznvUwvevolknvmgUvmtrmvUhszivwkxsOvmtrmvOhszwldviilihOsOlyq@4B2008FD98C1DD4

LogAximmetry: Display: UnrealBuildTool: ..\Plugins\Marketplace\BPImportDLL\Binaries\Win64\UnrealGame-BPImportDLL.dll : fatal error LNK1120: 2 externos sin resolver

LogAximmetry: Display: UnrealBuildTool: [10/11] WriteMetadata UnrealGame.version cancelled


Also for reference, this is the PluginCompile.Build.cs:


 
Profile Image
Eifert@Aximmetry
  -  

Hi,

It seems you solved the previous error by adding the CoreUObject dependency to the BPImportDLL.Build.cs file.
What you are experiencing now is a new error, where the linker doesn't find the "public: static struct UE::Math::TVector<double> const UE::Math::TVector<double>::ZeroVector" symbol. This symbol is in the Core module.
So you need to add this line: PrivateDependencyModuleNames.Add("Core");  to BPImportDLL.Build.cs file. Besides the PrivateDependencyModuleNames.Add("CoreUObject"); dependency you already added.

Warmest regards,

 
Profile Image
HerrLorenzo
  -  

That's already added! Check the last image in the post for reference, we've added Core, CoreUObject, Engine and InputCore.

Besides, Unreal Engine is compiling and linking it correctly when we package the plugin, while Unreal Engine for Aximmetry isn't.

It looks like a problem when creating the DLL (UnrealGame-BPImportDLL.dll), as it disappears when we don't build in module, and Unreal Engine by itself isn't generating any linker errors, only Unreal Engine for Aximmetry.

 
Profile Image
HerrLorenzo
  -  

I found the root of the problem and it's working correctly now.

I went into Unreal Engine and built with the same configuration as Aximmetry (LinkType = Modular), and there I was able to see that the Unreal Build Tool couldn't generate .dll correctly because it wasn't able to find the necessary .lib files for the requested modules (Engine, Core, etc), the error was LNK1181.

Now this is strange, as all the necessary files are there for Unreal to build (all the .obj and .ipch in /UE_5.1/Engine/Intermediate/Build/Win64/UnrealGame/Development/[ModuleName]) but it wasn't building them, so there was no .lib to link against.

Unreal Engine for Aximmetry was trying to find functions in the .lib that I guess were corrupt or just not there at all. I believe the problem was corrupt .obj or .ipch files in the Unreal Engine module.

A clean reinstall of Unreal Engine got me rid of all problems and I'm now able to build the plugin correctly.

I'm leaving this here just in case someone has the same problem in the future, thanks for your help anyways Eifert!

 

 
Profile Image
Eifert@Aximmetry
  -  

Hi,

I am glad you managed to solve the issue.

It could be that the source of the problem was not corrupted files. In certain cases, there is an Unreal issue where the Unreal's build system doesn't detect it needs to rebuild certain files.
If you run again into the same issue, you might be able to fix it by deleting the 'Intermediate' folder instead of a clean reinstall of Unreal Engine. The intermediate folder's default location is at: C:\Program Files\Epic Games\UE_5.1\Engine\Intermediate

Warmest regards,

 
Profile Image
HerrLorenzo
  -  

Thanks Eifert!

I tried deleting intermediates first, but it game me other error related to a .dll UBT was failing to find. It did seem like I was close tho (and it's much more probable that it's just not rebuilding them correctly, as you say, instead of corrupted files), so if anyone has a similar problem and is reading this, it's definitely worth trying before completely reinstalling :)

;