I’ve been trying to follow the tutorials on playfab to integrate UnrealBlueprintSDK. I can compile the code fine, but when I want to call the blueprintcallable methods in my C++ code, I get linker errors.
In my header, I include this:
#include "GameFramework/GameMode.h"
#include "PlayFabClientModels.h"
#include "PlayFabClientAPI.h"
/**
*
*/
UCLASS()
class ITEMS_API AItemsGameMode : public AGameMode
{
GENERATED_BODY()
public:
AItemsGameMode ();
virtual void BeginPlay() override;
}
and in my source file, I make the call to PlayFab’s loginwithcustomid method, as shown in the guide I linked above:
void AItemsGameMode::BeginPlay()
{
//Override this if you want more logic before starting the game
StartGame();
Super::BeginPlay();
// Create Request
FClientLoginWithCustomIDRequest request;
request.CustomId = "GettingStartedGuide";
request.CreateAccount = true;
request.InfoRequestParameters = nullptr;
// Set up Callbacks
UPlayFabClientAPI::FDelegateOnSuccessLoginWithCustomID onSuccess; onSuccess.BindUFunction(this, "OnLoginOrRegister");
UPlayFabClientAPI::FDelegateOnFailurePlayFabError onError; onError.BindUFunction(this, "OnSharedError");
// Make API Call
UPlayFabClientAPI* callObj = UPlayFabClientAPI::LoginWithCustomID(request, onSuccess, onError, nullptr);
// Extra activation step for UE BP
callObj->Activate();
}
However, I still get linker errors:
ItemsGameMode.cpp.obj : error LNK2019: unresolved external symbol "public: static class UPlayFabClientAPI * __cdecl UPlayFabClientAPI::LoginWithCustomID(struct FClientLoginWithCustomIDRequest,class UPlayFabClientAPI::FDelegateOnSuccessLoginWithCustomID,class UPlayFabClientAPI::FDelegateOnFailurePlayFabError,class UObject *)" (?LoginWithCustomID@UPlayFabClientAPI@@SAPEAV1@UFClientLoginWithCustomIDRequest@@VFDelegateOnSuccessLoginWithCustomID@1@VFDelegateOnFailurePlayFabError@1@PEAVUObject@@@Z) referenced in function "public: virtual void __cdecl AItemsGameMode::BeginPlay(void)" (?BeginPlay@AItemsGameMode@@UEAAXXZ)
2>D:\p4w\Unreal\TestGame\Binaries\Win64\UE4Editor-TestGame-Win64-DebugGame.dll : fatal error LNK1120: 1 unresolved externals
I also added “PlayFab” to my PublicDependencyModuleNames list in my build.cs file as well.
The method that is throwing the linker error is nothing out of ordinary. It resides in PlayFabClientAPI.h
// callbacks
DECLARE_DYNAMIC_DELEGATE_TwoParams(FDelegateOnSuccessLoginWithCustomID, FClientLoginResult, result, UObject*, customData);
/** Signs the user in using a custom unique identifier generated by the title, returning a session identifier that can subsequently be used for API calls which require an authenticated user */
UFUNCTION(BlueprintCallable, Category = "PlayFab | Client | Authentication ", meta = (BlueprintInternalUseOnly = "true"))
static UPlayFabClientAPI* LoginWithCustomID(FClientLoginWithCustomIDRequest request,
FDelegateOnSuccessLoginWithCustomID onSuccess,
FDelegateOnFailurePlayFabError onFailure, UObject* customData);
How do I fix this linker error?