cancel
Showing results for 
Search instead for 
Did you mean: 

Is anyone using the Meta XR plugin in their C++ code?

jsbmg
Honored Guest

In my project, I'd like to write some of the functionality in C++ vs. blueprints.

However, I'm unable to get past linker errors when calling functions from the Meta XR plugin. Specifically, I'm trying to create the custom Pawn, with the Oculus Controller Component.

I've added the following to the .Build.cs file:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "XRBase", "OculusXRInput", "OculusXRHMD" });

But adding this code (along with the relevant #include):

 

	UOculusXRControllerComponent* MyController = CreateDefaultSubobject<UOculusXRControllerComponent>(TEXT("MotionControllerRight"));

 

Results in this compile error:

 

XRPawn.cpp.obj : error LNK2019: unresolved external symbol "private: static class UClass * __cdecl UOculusXRControllerComponent::GetPrivateStaticClass(void)" (?GetPrivateStaticClass@UOculusXRControllerComponent@@CAPEAVUClass@@XZ) referenced in function "public: __cdecl AXRPawn::AXRPawn(void)" (??0AXRPawn@@QEAA@XZ)
C:\Users\XYZ\Documents\Unreal Projects\XR_Switch\Binaries\Win64\UnrealEditor-XR_Switch.patch_0.exe : fatal error LNK1120: 1 unresolved externals

 

 

1 REPLY 1

jsbmg
Honored Guest
Ok. I figured this one out. In case anyone has the same issue, here's what's going on. For some reason, UOculusXRControllerComponent is not exported with the *_API macro, so it's not available. I'm not sure why, because UOculusXRHandComponent IS exported. I'm not an Unreal or C++ expert so I'm no sure why this is the way it is. But now I understand why I can't import UOculusXRControllerComponent, but I can use UOculusXRHandComponent.
 
Meta - Is there a reason why UOculusXRHandComponent is exported with the _API macro, but UOCulusXRControllerComponent is not?