question

Carl Winder avatar image
Carl Winder asked

Compiler errors

I'm creating a C++ DLL as a wrapper around the PlayFab SDK.

I've installed the PlayFab SDK NuGet package but when I try and implement the quickstart here: https://docs.microsoft.com/en-us/gaming/playfab/sdks/playfab-cpp/quickstart-windows in it, I get some errors.

Using:

PlayFabSettings::staticSettings->titleId

I get:

use of undefined type 'PlayFab::PlayFabApiSettings

When I comment out that line I then get linker errors:

LNK2019	unresolved external symbol "public: static void __cdecl PlayFab::PlayFabClientAPI::LoginWithCustomID

Here is my code:

#include "pch.h"
#include "PlayFabCustomLogin.h"


#include "playfab/PlayFabError.h"
#include "playfab/PlayFabClientDataModels.h"
#include "playfab/PlayFabClientApi.h"
#include "playfab/PlayFabSettings.h"
using namespace PlayFab;
using namespace ClientModels;


void OnLoginSuccess(const LoginResult& result, void* customData);
void OnLoginFail(const PlayFabError& error, void* customData);


void L42OnlineServices::PlayFabCustomLogin::set_data(PlayFabLoginData data)
{
	//PlayFabSettings::staticSettings->titleId = data.TitleId;
}


void L42OnlineServices::PlayFabCustomLogin::login(void(*on_success)(PlayFabLoginResult data), void(*on_error)(PlayFabLoginResult data))
{
	LoginWithCustomIDRequest request;
	request.CreateAccount = true;
	request.CustomId = "Custom_Id";


	PlayFabClientAPI::LoginWithCustomID(request, OnLoginSuccess, OnLoginFail);
}


void OnLoginSuccess(const LoginResult& result, void* customData)
{
	//	success
}


void OnLoginFail(const PlayFabError& error, void* customData)
{
	//	fail
}


I've probably done something wrong but I'm not sure what it could be.

sdks
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

Adding the following “include” statement should fix your issue:

#include "playfab/PlayFabApiSettings.h"

By looking at the source code:

https://github.com/PlayFab/XPlatCppSdk/blob/a45af87220dfa0d58637dbadc4f7bd19d11bf436/code/include/playfab/PlayFabSettings.h#L28

Seems that the problem is that the class PlayFabApiSettings is declared but not defined, therefore, adding “#include “playfab/PlayFabApiSettings.h"” fixes it.

If you use the source code directly into your project, you can also add this "include" into "PlayFabSettings.h", that should also fix it.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Carl Winder avatar image Carl Winder commented ·

I ended up using the PlayFab Unreal Plugin as recommended by Microsoft.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Carl Winder commented ·

Glad to hear that you got it working:)

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.