I tried to add the LeapController component to a default character, but so far I can’t managed to link the code.
In the Char.h I include “LeapController.h” and define a pointer to the component.
class ULeapController* LeapController;
In the Char.cpp, I instantiate the LeapController in the class constructor
ALeapCharacter::ALeapCharacter()
{
PrimaryActorTick.bCanEverTick = true;
LeapController = CreateDefaultSubobject<ULeapController>(TEXT("LeapControllerComponent"));
}
But end up getting the following link error:
LeapCharacter.cpp.obj : error LNK2019: unresolved external symbol "private: static class UClass * __cdecl ULeapController::GetPrivateStaticClass(wchar_t const *)" (?GetPrivateStaticClass@ULeapController@@CAPEAVUClass@@PEB_W@Z) referenced in function "public: class ULeapController * __cdecl UObject::CreateDefaultSubobject<class ULeapController>(class FName,bool)" (??$CreateDefaultSubobject@VULeapController@@@UObject@@QEAAPEAVULeapController@@VFName@@_N@Z)
Is there another step I’m forgetting about?
Edit:
It seems that adding the MinimalAPI tag for the ULeapController class fixes the compilation error to instantiate the component.
UCLASS(MinimalAPI, ClassGroup=Input, meta=(BlueprintSpawnableComponent))
class ULeapController : public UActorComponent
But the same kind of linking error happen when using a method of ULeapController.
Example when using the EnableBackgroundTracking:
LeapCharacter.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl ULeapController::EnableBackgroundTracking(bool)" (?EnableBackgroundTracking@ULeapController@@QEAAX_N@Z) referenced in function "public: __cdecl ALeapCharacter::ALeapCharacter(void)" (??0ALeapCharacter@@QEAA@XZ)
Using the LEAPMOTION_API tag for the class definition of ULeapController does seem to export all methods.
class LEAPMOTION_API ULeapController : public UActorComponent
Is it intended?