Problem with Google Play Game Services (DEF-2896)

I’m trying to integrate Google Play Games Services for C++ and I’m getting this output from build server:

Description Resource  Path  Location  Type
Build server output: javac -source 1.6 -target 1.6 -classpath /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//ext/share/java/android-support-v4.jar:/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//ext/share/java/android.jar:/tmp/job6834724248307980917/build/tmped21d7bc-e57d-41a6-a3ff-48a455df0a5drjava/classes -d /tmp/job6834724248307980917/build/tmped21d7bc-e57d-41a6-a3ff-48a455df0a5drjava/classes @/tmp/job6834724248307980917/build/tmped21d7bc-e57d-41a6-a3ff-48a455df0a5drjava/sources.txt
warning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning

jar cf /tmp/job6834724248307980917/build/tmped21d7bc-e57d-41a6-a3ff-48a455df0a5drjava/R.jar -C /tmp/job6834724248307980917/build/tmped21d7bc-e57d-41a6-a3ff-48a455df0a5drjava/classes .

dx --dex --output /tmp/job6834724248307980917/build/classes.dex /tmp/job6834724248307980917/build/tmped21d7bc-e57d-41a6-a3ff-48a455df0a5drjava/R.jar  /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//ext/share/java/facebooksdk.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//ext/share/java/bolts-android-1.2.0.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//ext/share/java/google-play-services.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//ext/share/java/android-support-v4.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//ext/share/java/in-app-purchasing-2.0.61.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/glfw_android.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/facebook_android.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/gamesys_android.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/iap_android.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/push_android.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/adtruth_android.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/sound_android.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/webview_android.jar /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//share/java/iac_android.jar 

arm-linux-androideabi-g++ -c -g -gdwarf-2 -fpic -ffunction-sections -fstack-protector -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -fno-exceptions -funwind-tables --sysroot=/opt/android/android-ndk-r10e/platforms/android-14/arch-arm -DANDROID -Wa,--noexecstack -DDM_PLATFORM_ANDROID -DLUA_BYTECODE_ENABLE -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -std=c++11  -Iupload/gpgservices/include/  -I/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//include -I/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//sdk/include  -I/opt/android/android-ndk-r10e/sources/android/native_app_glue -I/opt/android/android-ndk-r10e/sources/android/cpufeatures -I/opt/android/tmp/android-ndk-r10e/platforms/android-14/arch-arm/usr/include -I/opt/android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/include -I/opt/android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include  upload/gpgservices/src/gpgservices_test.cpp -obuild/gpgservices_test.cpp_0.o

arm-linux-androideabi-g++ -c -g -gdwarf-2 -fpic -ffunction-sections -fstack-protector -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -fno-exceptions -funwind-tables --sysroot=/opt/android/android-ndk-r10e/platforms/android-14/arch-arm -DANDROID -Wa,--noexecstack -DDM_PLATFORM_ANDROID -DLUA_BYTECODE_ENABLE -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -std=c++11  -Iupload/gpgservices/include/  -I/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//include -I/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//sdk/include  -I/opt/android/android-ndk-r10e/sources/android/native_app_glue -I/opt/android/android-ndk-r10e/sources/android/cpufeatures -I/opt/android/tmp/android-ndk-r10e/platforms/android-14/arch-arm/usr/include -I/opt/android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/include -I/opt/android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include  upload/gpgservices/src/gpgservices.cpp -obuild/gpgservices.cpp_1.o
In file included from /var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//include/dmsdk/sdk.h:11:0,
                 from upload/gpgservices/src/gpgservices.cpp:7:
/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//include/dmsdk/dlib/log.h:109:2: warning: #warning "DLIB_LOG_DOMAIN is not defined" [-Wcpp]
 #warning "DLIB_LOG_DOMAIN is not defined"
  ^

arm-linux-androideabi-ar rcs /tmp/job6834724248307980917/build/lib8c82c4dd-48cc-4c8d-a6a3-700c1fff87d0.a build/gpgservices_test.cpp_0.o build/gpgservices.cpp_1.o 

arm-linux-androideabi-g++ -c -g -gdwarf-2 -fpic -ffunction-sections -fstack-protector -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -fno-exceptions -funwind-tables --sysroot=/opt/android/android-ndk-r10e/platforms/android-14/arch-arm -DANDROID -Wa,--noexecstack -DDM_PLATFORM_ANDROID -DLUA_BYTECODE_ENABLE -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -std=c++11   -I/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//include -I/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//sdk/include  -I/opt/android/android-ndk-r10e/sources/android/native_app_glue -I/opt/android/android-ndk-r10e/sources/android/cpufeatures -I/opt/android/tmp/android-ndk-r10e/platforms/android-14/arch-arm/usr/include -I/opt/android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/include -I/opt/android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include  build/main.cpp -obuild/main_tmpb6eb97de-ad47-4e10-a682-a8164096cc28.o

arm-linux-androideabi-g++ --sysroot=/opt/android/android-ndk-r10e/platforms/android-14/arch-arm -lEGL -lGLESv1_CM -lGLESv2 build/main_tmpb6eb97de-ad47-4e10-a682-a8164096cc28.o  -o build/libdmengine.so -Wl,-soname=libdmengine.so -DDM_PLATFORM_ANDROID -DLUA_BYTECODE_ENABLE -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__   -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -landroid -fpic -z text -L/tmp/job6834724248307980917/build -L/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android  -Wl,-Bstatic -Wl,--start-group  -l8c82c4dd-48cc-4c8d-a6a3-700c1fff87d0 -lgpg  -Wl,--end-group -L/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//lib/armv7-android -L/var/extender/sdk/d1aad61476af35638fb6201574c7cc9869733aa6/defoldsdk//ext/lib/armv7-android -L/opt/android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a  -Wl,-Bstatic -lengine -lwebviewext -ladtruthext -lprofilerext -lfacebookext -liapext -lpushext -liacext -lrecord_null -lgameobject -lddf -lresource -lgamesys -lgraphics -lphysics -lBulletDynamics -lBulletCollision -lLinearMath -lBox2D -lrender -lscript -lluajit-5.1 -lextension -lhid -linput -lparticle -lrig -ldlib -ldmglfw -lgui -ltracking -lcrashext -lsound -lopenal_soft -ltremolo -lliveupdate  -Wl,-Bdynamic -lOpenSLES -lgnustl_static -lm -llog -lc -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -shared
upload/gpgservices/src/gpgservices.cpp:52: error: undefined reference to 'gpg::GameServices::Builder::SetOnAuthActionStarted(std::function<void (gpg::AuthOperation)>)'
upload/gpgservices/src/gpgservices.cpp:59: error: undefined reference to 'gpg::GameServices::Builder::SetOnAuthActionFinished(std::function<void (gpg::AuthOperation, gpg::AuthStatus)>)'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function gpg::Achievement::Achievement(std::__1::shared_ptr<gpg::AchievementImpl const>): error: undefined reference to 'std::__1::__shared_weak_count::__add_shared()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function gpg::Achievement::Achievement(gpg::Achievement const&): error: undefined reference to 'std::__1::__shared_weak_count::__add_shared()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function std::__1::shared_ptr<gpg::AchievementImpl const>::~shared_ptr(): error: undefined reference to 'std::__1::__shared_weak_count::__release_shared()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function gpg::Achievement::operator=(gpg::Achievement const&): error: undefined reference to 'std::__1::__shared_weak_count::__add_shared()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function std::__1::__function::__func<gpg::InternalCallback<gpg::AchievementManager::FetchResponse const&> gpg::InternalizeBlockingRefHelper<gpg::AchievementManager::FetchResponse>(gpg::BlockingHelper<gpg::AchievementManager::FetchResponse>)::{lambda(gpg::AchievementManager::FetchResponse const&)#1}, std::__1::allocator<{lambda(gpg::AchievementManager::FetchResponse const&)#1}>, void (gpg::AchievementManager::FetchResponse const&)>::operator()(gpg::AchievementManager::FetchResponse const&): error: undefined reference to 'std::__1::mutex::lock()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function std::__1::__function::__func<gpg::InternalCallback<gpg::AchievementManager::FetchResponse const&> gpg::InternalizeBlockingRefHelper<gpg::AchievementManager::FetchResponse>(gpg::BlockingHelper<gpg::AchievementManager::FetchResponse>)::{lambda(gpg::AchievementManager::FetchResponse const&)#1}, std::__1::allocator<{lambda(gpg::AchievementManager::FetchResponse const&)#1}>, void (gpg::AchievementManager::FetchResponse const&)>::operator()(gpg::AchievementManager::FetchResponse const&): error: undefined reference to 'std::__1::condition_variable::notify_all()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function std::__1::__function::__func<gpg::InternalCallback<gpg::AchievementManager::FetchResponse const&> gpg::InternalizeBlockingRefHelper<gpg::AchievementManager::FetchResponse>(gpg::BlockingHelper<gpg::AchievementManager::FetchResponse>)::{lambda(gpg::AchievementManager::FetchResponse const&)#1}, std::__1::allocator<{lambda(gpg::AchievementManager::FetchResponse const&)#1}>, void (gpg::AchievementManager::FetchResponse const&)>::operator()(gpg::AchievementManager::FetchResponse const&): error: undefined reference to 'std::__1::mutex::unlock()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function std::__1::__function::__func<gpg::InternalCallback<gpg::AchievementManager::FetchResponse const&> gpg::InternalizeBlockingRefHelper<gpg::AchievementManager::FetchResponse>(gpg::BlockingHelper<gpg::AchievementManager::FetchResponse>)::{lambda(gpg::AchievementManager::FetchResponse const&)#1}, std::__1::allocator<{lambda(gpg::AchievementManager::FetchResponse const&)#1}>, void (gpg::AchievementManager::FetchResponse const&)>::operator()(gpg::AchievementManager::FetchResponse const&): error: undefined reference to 'std::__1::mutex::unlock()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function std::__1::__function::__func<gpg::InternalCallback<gpg::UIStatus const&> gpg::InternalizeBlockingRefHelper<gpg::UIStatus>(gpg::BlockingHelper<gpg::UIStatus>)::{lambda(gpg::UIStatus const&)#1}, std::__1::allocator<{lambda(gpg::UIStatus const&)#1}>, void (gpg::UIStatus const&)>::operator()(gpg::UIStatus const&): error: undefined reference to 'std::__1::mutex::lock()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function std::__1::__function::__func<gpg::InternalCallback<gpg::UIStatus const&> gpg::InternalizeBlockingRefHelper<gpg::UIStatus>(gpg::BlockingHelper<gpg::UIStatus>)::{lambda(gpg::UIStatus const&)#1}, std::__1::allocator<{lambda(gpg::UIStatus const&)#1}>, void (gpg::UIStatus const&)>::operator()(gpg::UIStatus const&): error: undefined reference to 'std::__1::condition_variable::notify_all()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:all.cc:function std::__1::__function::__func<gpg::InternalCallback<gpg::UIStatus const&> gpg::InternalizeBlockingRefHelper<gpg::UIStatus>(gpg::BlockingHelper<gpg::UIStatus>)::{lambda(gpg::UIStatus const&)#1}, std::__1::allocator<{lambda(gpg::UIStatus const&)#1}>, void (gpg::UIStatus const&)>::operator()(gpg::UIStatus const&): error: undefined reference to 'std::__1::mutex::unlock()'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:achievement_manager.cc:function std::__1::__basic_string_common<true>::__throw_length_error() const [clone .isra.15]: error: undefined reference to 'std::logic_error::logic_error(char const*)'
/tmp/job6834724248307980917/upload/gpgservices/lib/armv7-android/libgpg.a:md5_util.cc:function std::__1::__basic_string_common<true>::__throw_length_error() const [clone .isra.15]: error: undefined reference to 'std::logic_error::logic_error(char const*)'

And so on ...

Contents of ext.manifest:

name: "GPGServices"

platforms:
  armv7-android:
    context:
        flags: ["-std=c++11"]

Code I’m trying to run:


#define LIB_NAME "GPGServices"
#define MODULE_NAME "gpgservices"
#include <dmsdk/sdk.h>
#include <jni.h>
#include "gpg/android_initialization.h"
#include "gpg/android_platform_configuration.h"
#include "gpg/builder.h"
#include "gpg/game_services.h"

bool is_auth_in_progress_ = false;
std::unique_ptr<gpg::GameServices> game_services_;


static int Init(lua_State* L)
{

    gpg::AndroidPlatformConfiguration platform_configuration;
    gpg::GameServices::Builder::OnAuthActionStartedCallback started_callback;
    gpg::GameServices::Builder::OnAuthActionFinishedCallback finished_callback;
    game_services_ = gpg::GameServices::Builder()
                .SetDefaultOnLog(gpg::LogLevel::VERBOSE)
                .SetOnAuthActionStarted([started_callback](gpg::AuthOperation op) {
                    is_auth_in_progress_ = true;
                })
                .SetOnAuthActionFinished([finished_callback](gpg::AuthOperation op,
                                                             gpg::AuthStatus status) {
                        printf("Sign in finished with a result of %d \n", status);
                    is_auth_in_progress_ = false;
                })
                .Create(platform_configuration);
    return 1;
}

static const luaL_reg Module_methods[] =
{
    {"init", Init},
    {0, 0}
};

static void LuaInit(lua_State* L)
{
    int top = lua_gettop(L);

    // Register lua names
    luaL_register(L, MODULE_NAME, Module_methods);

    lua_pop(L, 1);
    assert(top == lua_gettop(L));
}

dmExtension::Result AppInitializeGPGServices(dmExtension::AppParams* params)
{



    return dmExtension::RESULT_OK;
}

dmExtension::Result InitializeGPGServices(dmExtension::Params* params)
{
    // Init Lua
    LuaInit(params->m_L);
    printf("Registered %s Extension\n", MODULE_NAME);
    return dmExtension::RESULT_OK;
}

dmExtension::Result AppFinalizeGPGServices(dmExtension::AppParams* params)
{
    return dmExtension::RESULT_OK;
}

dmExtension::Result FinalizeGPGServices(dmExtension::Params* params)
{
    return dmExtension::RESULT_OK;
}


// Defold SDK uses a macro for setting up extension entry points:
//
// DM_DECLARE_EXTENSION(symbol, name, app_init, app_final, init, update, on_event, final)

DM_DECLARE_EXTENSION(GPGServices, LIB_NAME, AppInitializeGPGServices, AppFinalizeGPGServices, InitializeGPGServices, 0, 0, FinalizeGPGServices)

So, does anybody know what is happening?

When you see this, it’s a hint that some of the base c++ libs used are at odds with each other.
What lib to choose is done by specifying the flag “-stdlib” to the compiler. When you use C++11, you’ll probably want to add this:

flags: ["-std=c++11", "-stdlib=libc++"]
1 Like

Mathias, thanks for reply! I’ve made, what you suggested, but I’ve got:

arm-linux-androideabi-g++: error: unrecognized command line option '-stdlib=libc++'

I’ve dived into android docs a little bit, and created standalone toolchain with libc++ with this command:

build/tools/make-standalone-toolchain.sh --platform=android-14 --arch=arm --system=windows-x86_64 --install-dir=../toolchain --stl=libc++

And then tried to compile and link my code like this:

./bin/arm-linux-androideabi-g++.exe -c -I{path_to_project}/gpgservices/include -std=c++11 -{path_to_project}/gpgservices/src/gpgservices_test.cpp 
./bin/arm-linux-androideabi-g++.exe  -L{path_to_project}/gpgservices/lib/armv7-android  gpgservices_test.o  -lgpg  -lz -lc++_shared

And that worked!

Then I’ve tried to pass c++_shared to build server like this

flags: ["-std=c++11", "-lc++_shared"]

and this:

libs: ["c++_shared"]

but I’ve got error about unrecognized options.
So is there a way to pass libc++ to build server as a standard library?

Quick note, the “-l” is for libraries, when linking. So it would go into the “linkFlags”, without the “-l” (as you wrote in your second line)

flags: ["-std=c++11"]
libs: ["c++_shared"]

Unfortunately, the “c++_shared” isn’t whitelisted in the build settings yet, but I’ll try adding it this sprint, to see if that helps this issue.

1 Like

Thanks! It would be great!

Also, I tried to add libz, and it seems not to be whitelisted too

Have you listed it as “libz” or “z”?

like this:

libs: ["z"]
1 Like

It’s working in my project on iOS

libs:       ["z", "c++", "sqlite3", "xml2"]

I’m building for android, maybe whitelisted libs are different for different platforms

They are, and in this case the list is too short :confused:
I’m looking into it!

2 Likes

@Mathias_Westerdahl hi, is there any progress on this issue?

1 Like

Yes, it unfortunately got side tracked by other things, but it’s scheduled for this release (which should happen on monday)

4 Likes

This was solved in release 1.2.114

However, you mentioned that you still have the same problem? What editor are you running and what version is it?

I’m using 1.2.113, I’ll update later today and report about results!

@Mathias_Westerdahl, I’ve checked now with 1.2.115 and all is working! sorry, I didn’t update editor, because I thought, that changes concern only server code.
Thanks for help!

4 Likes

Waiting for this extention on assets portal :slight_smile:

5 Likes

This is not my priority right now, so l hope somebody more clever will do it before me! :slight_smile:

Ok, we are looking for the Hero who can make native extensions for https://developers.google.com/games/services/ :slight_smile:

4 Likes