UPhysicsThrusterComponent linker error

Hello,

When attempting to attach a UPhysicsThrusterComponent to an actor e.g.:

class AExample : public APawn
{
public:
	GENERATED_UCLASS_BODY()

	UPROPERTY(Category = Physics, VisibleDefaultsOnly, BlueprintReadOnly)
		TSubobjectPtr<class UPhysicsThrusterComponent> Thruster;
};

AExample::AExample(const class FPostConstructInitializeProperties& PCIP)
{
	Thruster = PCIP.CreateDefaultSubobject<UPhysicsThrusterComponent>(this, TEXT("Thruster0"));
	Thruster->AttachTo(RootComponent);
}

You get a linker error:

error LNK2019: unresolved external symbol "private: static class UClass * __cdecl UPhysicsThrusterComponent::GetPrivateStaticClass(wchar_t const *)" (?GetPrivateStaticClass@UPhysicsThrusterComponent@@CAPEAVUClass@@PEB_W@Z) referenced in function "public: class UPhysicsThrusterComponent * __cdecl FPostConstructInitializeProperties::CreateDefaultSubobject<class UPhysicsThrusterComponent,class UPhysicsThrusterComponent>(class UObject *,class FName,bool,bool,bool)const " (??$CreateDefaultSubobject@VUPhysicsThrusterComponent@@V1@@FPostConstructInitializeProperties@@QEBAPEAVUPhysicsThrusterComponent@@PEAVUObject@@VFName@@_N22@Z)

From discussing with others all I can tell is because potentially the UPhysicsThrusterComponent has not been exposed properly to C++, most likely due to it only anticipated being used in blueprints.

I actually changed the source code to add MinimalAPI onto the Component class definition and it does appear to link correctly, though I’m not sure if this is the correct solution:

UCLASS(hidecategories = (Object, Mobility, LOD), ClassGroup = Physics, showcategories = Trigger, HeaderGroup = Component, meta = (BlueprintSpawnableComponent), MinimalAPI)
class UPhysicsThrusterComponent : public USceneComponent

Thanks

.

Hi ,

Using MinimalAPI is currently the best option for this issue. What is happening here is that the PhysicsThrusterComponent is in the Engine Module, and is not visible to your Game Module. I will see if there might be anything we can do to make this component a little easier to use.

Ah, thank you for looking into this. I just ran into this issue today as well… iterating through the Components on my APawn, and I cannot cast them to UPhysicsThrusterComponent.

So, I must be doing something wrong. I added “, MinimalAPI” to the end of the UCLASS definition of PhysicsThrusterComponent.h, just as described in the question. I’m still getting the same linker error. Any ideas?
All I want is to work with thrusters in C++.

Using UE 4.3.1.
One thing I noted is I got a compile error if I copied & pasted his UCLASS statement entirely, on this part: “HeaderGroup = Component”
That was also the only thing that differed from my copy.

Error 2 error LNK2019: unresolved external symbol “private: static class UClass * __cdecl UPhysicsThrusterComponent::GetPrivateStaticClass(wchar_t const *)” (?GetPrivateStaticClass@UPhysicsThrusterComponent@@CAPEAVUClass@@PEB_W@Z) referenced in function "public: class UPhysicsThrusterComponent * __cdecl FPostConstructInitializeProperties::CreateDefaultSubobject<class UPhysicsThrusterComponent,class UPhysicsThrusterComponent>(class UObject *,class FName,bool,bool,bool)const " (??$CreateDefaultSubobject@VUPhysicsThrusterComponent@@V1@@FPostConstructInitializeProperties@@QEBAPEAVUPhysicsThrusterComponent@@PEAVUObject@@VFName@@_N22@Z) C:\Users\Andreas\Documents\Unreal Projects\Birds\Intermediate\ProjectFiles\BirdsPawn.cpp.obj Birds

Hi @anjdreas,

Do you also have an include for the PhysicsThrusterComponent? Make sure you have this line in your header file:

#include "PhysicsEngine/PhysicsThrusterComponent.h"

You don’t need to include the HeaderGroup class specifier. That keyword was removed in 4.2 and is no longer recognized by UHT.

Thanks, I did not. Somehow I thought it would be included as all the other classes are.

Hi ,

Any idea when we might see a fix for this? I can work around it atm using the MinimalAPI trick, but its an issue for our artists who dont necessarily want to compile the full source, to open the project.

Cheers,

Hi ,

I had lost track of this post, sorry about that. I have a feature request entered asking that the PhysicsThrusterComponent be exposed outside of the Engine module. I still do not have any information for when this will happen, though.

Thanks !!

Is there any way I can “watch” that feature request?
Otherwise I will keep an eye on the change notes.
Cheers,

This change is now in main, but won’t make it into 4.5 as we’ve already branched. It should be in 4.6