My cpp file:
#define EXTENSION_NAME DefGadsmeSDK
#define LIB_NAME "DefGadsmeSDK"
#define MODULE_NAME "def_gadsme_sdk"
#define DLIB_LOG_DOMAIN LIB_NAME
#include <dmsdk/sdk.h>
#include "def_gadsme_sdk.h"
#include <cmath>
#include <iostream>
// Import the SDK header on other platforms
#include "GadsmeSDK.h"
using namespace gadsme;
namespace dmGadsmeSDK {
static std::string str = "my_key";
static void set_sandbox(bool value) {
// Gadsme_setForceSandbox(true);
}
static const luaL_reg Module_methods[] =
{
{0, 0}
};
static void LuaInit(lua_State* L)
{
int top = lua_gettop(L);
luaL_register(L, MODULE_NAME, Module_methods);
lua_pop(L, 1);
assert(top == lua_gettop(L));
}
dmExtension::Result InitializeDefGadsmeSDK(dmExtension::Params* params)
{
LuaInit(params->m_L);
dmLogInfo("Registered extension DefGadsmeSDK");
Initialize_Ext();
////Delayed CRASH after calling Gadsme_setGameId
Gadsme_setGameId(Gadsme_str(str));
set_sandbox(true);
// Gadsme_init();
return dmExtension::RESULT_OK;
}
DM_DECLARE_EXTENSION(EXTENSION_NAME, LIB_NAME, 0, 0, InitializeDefGadsmeSDK, 0, 0, 0)
} //namespace
Part of GadsmeSDK.h
#define GADSME_SDK_H
#include <string>
#include <memory>
#include <functional>
#include <vector>
#include <map>
#include <utility>
#if defined(__ANDROID__)
#define GADSME_ANDROID 1
#elif defined(_WIN32)
#define GADSME_WINDOWS 1
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#define GADSME_IOS 1
#else
#define GADSME_MAC 1
#endif
#endif
#if GADSME_ANDROID
#include <jni.h>
#endif
#if defined _WIN32 || defined __CYGWIN__
#ifdef BUILDING_GADSME
#ifdef __GNUC__
#define GADSME_PUBLIC __attribute__ ((dllexport))
#else
#define GADSME_PUBLIC __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#define GADSME_PUBLIC __attribute__ ((dllimport))
#else
#define GADSME_PUBLIC __declspec(dllimport)
#endif
#endif
#define GADSME_HIDDEN
#else
#if __GNUC__ >= 4
#define GADSME_PUBLIC __attribute__ ((visibility ("default")))
#define GADSME_HIDDEN __attribute__ ((visibility ("hidden")))
#else
#define GADSME_PUBLIC
#define GADSME_HIDDEN
#endif
#endif
/**
* Gadsme SDK namespace.
*
* The SDK can be initialized from any thread, but any following call
* should be done from this same thread. Calling from another thread will
* cause a crash, unless using a method which is explicitly documented as
* being thread safe, and thus can be called from any thread without issues.
*/
namespace gadsme {
/// Type aliases
#if defined(_MSC_VER) && _MSC_VER < 1900
typedef std::shared_ptr< std::vector<unsigned char> > Gadsme_Bytes;
typedef std::shared_ptr<std::string> Gadsme_String;
typedef std::shared_ptr< std::map< std::string, gadsme::Gadsme_String> > Gadsme_StringStringMap;
typedef std::shared_ptr< std::vector<int> > Gadsme_IntArray;
#else
using Gadsme_Bytes = std::shared_ptr< std::vector<unsigned char> >;
using Gadsme_String = std::shared_ptr<std::string>;
using Gadsme_StringStringMap = std::shared_ptr< std::map< std::string, gadsme::Gadsme_String> >;
using Gadsme_IntArray = std::shared_ptr< std::vector<int> >;
#endif
...............................................
GADSME_PUBLIC Gadsme_String Gadsme_str(std::string str);
...............................................
GADSME_PUBLIC void Gadsme_setGameId(Gadsme_String gameId);
...............................................
}
ext.manifest
name: "DefGadsmeSDK"
platforms:
armv7-android:
context:
defines: ['__ANDROID__']
arm64-android:
context:
defines: ['__ANDROID__']