PlayFab/gsdk

libc++ compatible version for Unreal

narthur157 opened this issue ยท 18 comments

Is your feature request related to a problem? Please describe.
Linux servers in Unreal require the library to be compiled against libc++ to be statically linked.
I tried compiling dynamic versions of the library, but didn't have any luck with this when it came to actually packaging the project in Unreal

Describe the solution you'd like
library compiled against libc++

Describe alternatives you've considered
I tried for quite some time to compile this through VS, however I kept getting issues with jsoncpp trying to link against libstd.

Additional context
I solved this by using a modified version of the CMakeList from this PR: #70

project(GSDK_CPP_Linux)

set(CMAKE_CXX_COMPILER "clang++")

set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++")

add_library(GSDK_CPP_Linux
    cpp/cppsdk/gsdk.cpp
    cpp/cppsdk/gsdkConfig.cpp
    cpp/cppsdk/gsdkLog.cpp
    cpp/cppsdk/gsdkUtils.cpp
    cpp/cppsdk/jsoncpp.cpp
    cpp/cppsdk/ManualResetEvent.cpp
)

target_compile_options(GSDK_CPP_Linux PRIVATE -DGSDK_LINUX)
set_target_properties(GSDK_CPP_Linux PROPERTIES CXX_STANDARD 14)
target_include_directories(GSDK_CPP_Linux PRIVATE "cpp/cppsdk")

This is the CMakeLists.txt I used, with Ubuntu on WSL 2 in Windows. I was able to take the resulting .a file and link it in Unreal + deploy to PlayFab.

Note that I'm not sure the CMake version needs to be >= 3.2, so you could try setting this lower.

I also used the json include fix mentioned in #70

thanks @narthur157, we'll take a look ASAP!

Hi @narthur157 May I ask what your ubuntu setup is like? I'm trying to build the Linux GSDK but the build fails to find list when using libc++, I'm probably missing something silly as I'm not super familiar with Linux, any info would be appreciated! :)

Hi @narthur157 May I ask what your ubuntu setup is like? I'm trying to build the Linux GSDK but the build fails to find list when using libc++, I'm probably missing something silly as I'm not super familiar with Linux, any info would be appreciated! :)

Helps to install the right version of clang, I was trying to use clang 9, but moving to clang 10 has resolved the issue

I'd love to see this supported by the GSDK, using Unreal on Linux w/ PlayFab is a significant cost savings.

I managed to get everything working through WSL2 yesterday with Ubuntu 18.04, With relatively few steps:
From a clean Ubuntu install:

  1. apt update
  2. apt install clang-9 (I'm on ue4.25 and that's what the cross compiler uses)
  3. apt install cmake
  4. apt install libc++-dev

I also had to modify the cmake file to explicitly include libcurl release, and to use clang++-9, but other than that I was able to build through VSCode without much pain :)

Definitely agree with @narthur157 that UE plugin would make life much easier for unreal devs!

https://github.com/narthur157/playfab-gsdk-ue4
Here is the plugin

I'd love for PlayFab to fork this plugin and maintain it / improve it / publish it to the epic marketplace

It'd make sense for them to incorporate this into their existing plugin for UE perhaps?
https://github.com/PlayFab/UnrealMarketplacePlugin

wow, thanks @narthur157, great work! I'll see how/if we can incorporate this. Can you add a License file as well?

wow, thanks @narthur157, great work! I'll see how/if we can incorporate this. Can you add a License file as well?

No problem! Yup, done

@QHGDerek I'd prefer to keep them separate, since in most of the cases you don't need the full PlayFab SDK if you want to use GSDK. I may be 100% wrong here though, feel free to correct me if that's the case!

thanks @QHGDerek for the feedback, much appreciated. Additional question would be how hard it is to pull both SDKs (PlayFab SDK and GSDK)? They do have a different publishing path so it might be tricky to maintain them as a single entity.

@narthur157 thanks again for raising this issue. Since I just merged #70 the next step would be to create multiple targets in cmake (like one for straight linux, one for UE4 etc). Or maybe we can add env var/switch/etc. to support building for the different environments?

@dgkanatsios I agree with @QHGDerek, generally speaking if you're using the PlayFab plugin in UE, you'd want both the server and client stuff in a single project. Though understandable if it'd be a pain to maintain as a single thing. I would recommend at least having a link / some doco in the PlayFab plugin for UE pointing to the right version of GSDK to be used, as another engineer in my team ended up using an outdated version for a couple of days (the mark 1 stuff? I can't quite recall what he was using) before finding the proper version of the GSDK. ๐Ÿ‘

@Hayden-W I believe the UE build tools would make it possible to support both and contextualize how/when something gets built and for what platform, it's a pretty flexible environment for this exact sort of thing. I'd love to see this as part of the official release, utilizing linux dedicated servers for UE would be fantastic.

I am also having an issue with linking with GSDK which I built in Clang 10 on WSL with the UE4 toolchain (Clang 10 for UE4.26).. It seems like the UE4 toolchain pthread lib is missing this function..

2>ld.lld : error : undefined symbol: pthread_cond_clockwait