cancel
Showing results for 
Search instead for 
Did you mean: 

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

jsbmg
Explorer

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

 

 

3 REPLIES 3

jsbmg
Explorer
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?

ontnevertries
Honored Guest

This is especially frustrating because the literal documentation for the literal API lists this as available: https://developers.meta.com/horizon/reference/unreal/v72/class_u_oculus_x_r_controller_component/

 

Meta, what the **bleep**? 

Pjotr
Explorer

This feels like an oversight, especially since it's in the public folder. There has been multiple times that Epic also forgot to put API macros in front of their class/method names their code. There is btw nothing stopping you from exposing more functions from the plugin to other modules as you have the source of the plugin.