question

martinliu1993 avatar image
martinliu1993 asked

UE4 Compile Error: Cannot open include file PlayFabPrivatePCH.h

Hi, I've been trying to add C++ code to the UE4BPSDK that is provided. Namely, I am working with the ExampleProject created, and trying to incorporate some basic C++ code in to login using CustomID.

From here, I just copy and pasted the code into ExampleProjectGameMode::StartMatch

#include "PlayFabClientModels.h"


void AExampleProjectGameMode::StartMatch()
{
	// 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);
	// Extra activation step for UE BP
	callObj->Activate();
}

It said "PlayFabClientModels.h" not found, so I thought I had to add PlayFab to ExampleProject.Build.cs file to make it work.

// #define PF_UNREAL_OLD_4_14_TO_4_15


using UnrealBuildTool;


public class ExampleProject : ModuleRules
{
#if PF_UNREAL_OLD_4_14_TO_4_15
    public ExampleProject(TargetInfo Target)
#else
    public ExampleProject(ReadOnlyTargetRules ROTargetRules) : base(ROTargetRules)
#endif
    {
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "PlayFab" });


        PrivateDependencyModuleNames.AddRange(new string[] { "PlayFab" });


        // Uncomment if you are using Slate UI
        // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });


        // Uncomment if you are using online features
        // PrivateDependencyModuleNames.Add("OnlineSubsystem");
        // if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64))
        // {
        //        if (UEBuildConfiguration.bCompileSteamOSS == true)
        //        {
        //            DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
        //        }
        // }
    }
}


But it still didn't compile, and now it says Cannot open include file 'PlayFabPrivatePCH.h". The error is from "PlayFabEnums.h"

How do I use C++ code to login using CustomId, using UnrealBlueprintSDK?

Thanks

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.

1807605288 avatar image 1807605288 ♦ commented ·

Another PlayFab/Unreal customer is currently working on fixes to improve the C++ SDK for all of us.

That should be available in the next release.

0 Likes 0 ·
Montana Tuska avatar image Montana Tuska commented ·

I'm working with Paul on upgrading the C++ SDK. The BP SDK just wasn't capable of being as versatile, especially with the UObject restriction. My current working copy of the SDK is here. The version Paul will be releasing soon doesn't have Proxy as feature complete as this version. If you don't need blueprint PlayFab functions, then don't place the PlayFabProxy in your plugins. Currently Proxy is undergoing some optimizations, and is liable to change.

0 Likes 0 ·
1807605288 avatar image
1807605288 answered

Yes, I can confirm that you cannot make API calls from C++, and this feature doesn't actually work in our Blueprint SDK.

Here's the original blog that started everything:

https://blog.playfab.com/blog/cpp-sdk-updates

For clarity, I'll repeat the entire sequence of events here:

  1. 2 years ago, we did not have anyone at PlayFab familiar with Unreal, so we never had a great starting point for building an SDK/plugin ourselves from scratch.
  2. Two separate PlayFab customers independently created and submitted Unreal plugins to us at roughly the same time. They each had two separate focuses: C++ and Blueprints.
  3. Since then, we've maintained them, added tests, and generally learned how Unreal works and best practices.
  4. A few months ago, after the release of Unreal 4.16, we discovered that the CPP SDK faced upgrade challenges which were more significant than we'd faced in the past, where the Blueprint SDK faced fewer challenges, and SEEMED to be more feature complete.
  5. At the begining of August, Once we updated the Blueprint SDK to 4.17, we decided to discontinue the CPP SDK in favor of the Blueprint SDK, since it seemed to cover the full feature set.
  6. Customers quickly reported that they could not make C++ calls using the Blueprint SDK, and that our tests were incorrect, because they tested C++ calls from within the plugin. If called outside the plugin, you only get linker errors, because those calls aren't set up properly.
  7. We restored the CPP SDK for customers that want C++ calls, but we still haven't been able to update it to 4.17.
  8. Both SDKs are incomplete, and need major revisions, so we will be forced to replace them both with a new feature-complete plugin, once we can dedicate the time to do so, but this won't happen for at least a few months.
7 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.

Kain avatar image Kain commented ·

Thank you for much for this in-depth explanation, Paul. I'm really glad the two plugins were eventually consolidated to a single plugin, and sticking with the Blueprint versionseems like the best choice as it is easier to go from Blueprint to C++ than the other way around.

With some modifications, I was able to make PlayFab API calls using the source shared at
https://github.com/PlayFab/UnrealBlueprintSDK
using the contents of 'PlayFabClientSDK' within our local Game/Plugins/PlayFab folder.

0 Likes 0 ·
Kain avatar image Kain Kain commented ·

I hit a character limit to my followup post. Will try to post my steps again

0 Likes 0 ·
Kain avatar image Kain Kain commented ·
  1. Remove "EngineVersion" : "4.16.3" from PlayFab.uplugin, as it is not neccesary to version the PlugIn if building from source
  2. In PlayFabClientAPI.h, add #include "IHttpRequest.h" at the top (as martinliu1993 noted)
  3. In PlayFabClientAPI.h, make sure that class is accessible outside the DLL by having the class declaration look like this:
    class PLAYFAB_API UPlayFabClientAPI : public UOnlineBlueprintCallProxyBase
  4. In PlayFabEnums.h, comment out #include "PlayFabPrivatePCH.h", as Zhi Kang Shao noted)
  5. Within your PlayFab handling class (singleton or whatever), make sure your success and error delegates are UFUNCTION() and bind them like this:UPlayFabClientAPI::FDelegateOnSuccessLoginWithCustomID loginSuccessDelegate;
    loginSuccessDelegate.BindUFunction(this, "OnPlayFabLoginSuccess");
  6. If you are using Steam...
    IOnlineIdentityPtr pIdentityInt = Online::GetIdentityInterface(pWorld);
    FClientLoginWithSteamRequest loginRequest;
    loginRequest.SteamTicket = pIdentityInt->GetAuthToken(0);
    UPlayFabClientAPI* const pPlayFabClientAPI = UPlayFabClientAPI::LoginWithSteam(loginRequest, loginSuccessDelegate, loginFailureDelegate, nullptr);
    pPlayFabClientAPI->Activate();
0 Likes 0 ·
Montana Tuska avatar image Montana Tuska Kain commented ·

Haha, acutally, you should remove "OnlineSubsystemUtils" and "OnlineSubsystem" from the build.cs since those aren't even needed. Not add them as useless dependencies.

1 Like 1 ·
Show more comments
Zhi Kang Shao avatar image
Zhi Kang Shao answered

I noticed this too when I was playing with that SDK. Try removing the "#include PlayFabPrivatePCH.h", I don't believe its necessary.

5 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.

Kain avatar image Kain commented ·

For the unresolved externals, I had to add PLAYFAB_API to the class declaration at the top of PlayFabClientAPI.h

class PLAYFAB_API UPlayFabClientAPI : public UOnlineBlueprintCallProxyBase
,

For the unresolved externals, I had to add PLAYFAB_API to the class declaration at the top of PlayFavClientAPI.h

class PLAYFAB_API UPlayFabClientAPI : public UOnlineBlueprintCallProxyBase
1 Like 1 ·
martinliu1993 avatar image martinliu1993 Kain commented ·

Hey this fix worked thanks so much for your help!

In general, there were many things I had to do extra to setup the C++ calls to work correctly. Wish they had integrated them properly in the UnrealBlueprintSDK

1 Like 1 ·
Kain avatar image Kain martinliu1993 commented ·

Great! Your post was helpful, too. I found this blog post that explains the current state of PlayFab UE4 integration:

https://api.playfab.com/blog/cpp-sdk-updates

I figure it's a matter of time before they eventually sort that out.

0 Likes 0 ·
Show more comments
martinliu1993 avatar image martinliu1993 commented ·

So I removed the #include PlayFabPrivatePCH.h and it works. Also I had to add "Include IHttpRequest.h" to PlayFabClientAPI.h.

Now everything almost works, but I am still getting a linker error:

rror 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 "private: virtual void __cdecl AExampleProjectGameMode::StartMatch(void)" (?StartMatch@AExampleProjectGameMode@@EEAAXXZ) 1>C:\Users\marti\Desktop\PlayFabSDK\ExampleProject\Binaries\Win64\UE4Editor-ExampleProject-Win64-DebugGame.dll : fatal error LNK1120: 1 unresolved externals

I am not sure why this is here, I added the includes properly. These are the new includes in my ExampleGameMode.h

#include "ExampleProjectGameMode.h"
#include "PlayFabClientModels.h"
#include "PlayFabClientAPI.h"

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.