I’m getting the following linker error when compiling my class LNK2019: unresolved external symbol "private: static class UClass * __cdecl UHeterogeneousVolumeComponent::GetPrivateStaticClass(void)" (?GetPrivateStaticClass@UHeterogeneousVolumeComponent@@CAPEAVUClass@@XZ) referenced in function "class UHeterogeneousVolumeComponent * __cdecl NewObject<class UHeterogeneousVolumeComponent>(class UObject *,class FName,enum EObjectFlags,class UObject *,bool,struct FObjectInstancingGraph *)" (??$NewObject@VUHeterogeneousVolumeComponent@@@@YAPEAVUHeterogeneousVolumeComponent@@PEAVUObject@@VFName@@W4EObjectFlags@@0_NPEAUFObjectInstancingGraph@@@Z)
Happens both if I use NewObject outside the constructor or CreateDefaultSubobject inside the constructor. I have the correct include at the top of my header file.
I’ve found that linker errors sometime happens because I didn’t include a module in the Build.cs file but I have no idea what this would be as it’s just in the components folder in engine files.
But I guess you have already added it to your [project].Build.cs, right?
If not, try adding it - CoreUObject
Might be a st00pid take from me, but isn’t this happening because GetPrivateStaticClass is a private method ?
I remember that I had some similar errors while trying to use private members from different modules, so this also might be a case.
However, if you’re trying to access private members then this shouldn’t be possible in any way.
Maybe something wrong with the code itself. Can you post some snippet?
Might be a st00pid take from me, but isn’t this happening because GetPrivateStaticClass is a private method ?
I had thought the same but then why would the HeterogeneousVolumeComponent have it as private or not work compared to other components? Unless it’s just a minor bug that I have managed to stumble across
Here’s the non-constructor code - I was going to add the component to an array but I often just build as I go along and found that even this wouldn’t work. The constructor - CreateDefaultSubobject attempt I tried was even simpler, just creating the object.
“this” also refers to a component that inherits USceneComponent so I don’t know if that’s an issue (or even bad practice tbh)
First of all, GetPrivateStaticClass gets declared by a macro which UHT parser places in [class_name].generated.h.
Considering the above, you may encountered one of these issues, where one of the Intermediate files is borked and you need to recompile it.
Just to be sure, try this:
delete all these files:
– /[project]/Intermediate
– /[project]/Saved
– /[project]/Binaries
Clicking RMB at your .uproject file and use Generate Visual Studio project files
Open the solution file and recompile the project
I don’t know what UHeterogeneousVolumeComponent actually is.
I searched for this class and couldn’t find anything.
Is this something that you have declared, or class from some 3rd party plugin?
If yes, we might wanna look into its declaration.
If that’s class declared by different module than your project’s main module, then you may also wanna include CoreUObject in that said module.
If that’s not enough, then I’m running out of ideas… Sorry. Hope, someone gonna help you
delete all these files:
– /[project]/Intermediate
– /[project]/Saved
– /[project]/Binaries
Clicking RMB at your .uproject file and use Generate Visual Studio project files
Open the solution file and recompile the project
Unfortunately, this didn’t work so I’m thinking something else might be messed up as the component is not mine or 3rd party.
The component itself is located in UE_5.3/Engine/Source/Runtime/Engine/Classes/Components
I can place the wrapper actor (or whatever you would call it) in the level fine and can create a blueprint with the component fine as well, just not in C++.
Ahh, this explains everything. I’m still using Unreal 5.2, and this class seems to be something newly added in 5.3 - HeterogeneousVolumeComponent.h - #include "HeterogeneousVolumeComponent.h"
Well, the module for that should be Engine but I highly doubt you wouldn’t use it already.
At first, I thought this might be happening because said Component is declared under “Classes” directory instead of “Public”, but I just tried to instantiate a different Component from that place:
#include "CoreMinimal.h"
#include "Components/InputComponent.h"
void UMyComponent::MyFunction()
{
for (int i = 0; i < 10; ++i)
{
if (UInputComponent* InputComp = NewObject<UInputComponent>(this, FName(*FString::Printf(TEXT("Input Component %d")))))
{
UE_LOG(LogTemp, Warning, TEXT("Spawned"))
}
}
}
and for me it compiles just fine, so there must be an issue somewhere else…
After a little more testing, I found that using the Add Heterogeneous Volume Component in a blank Actor BP works fine too so I think as a (hopefully temporary) workaround, I’ll create a function in the child BP that adds these components to the array. Not ideal but hopefully it won’t be an issue in 5.4