SSL related linker errors Android NDK app and C++ client

I am trying to get the Nakama C++ client working with my Cocos2d-x app on Android. For iOS, Mac and Linux I have it working perfectly, but for Android I run into problems related to OpenSSL/BoringSSL.

First of all I ran into issues with the .mk file for the Nakama C++ Android client. It contains references to libraries that are not included. I have changed it to reflect the libraries that are included, but now I get linker errors as my app is also statically linked with OpenSSL (for libcurl, which I use heavily also).

  • when I incude both the Nakama boring SSL libs and OpenSSL I get errors with duplicates
  • when I remove the OpenSSL libs, I get errors on missing references in Curl
  • when I remove the Boring libs i get missing references in libcpprest

How can I solve this? I am using Android Studio with NDK-BUILD and am an absolute n00b when it comes to the Android build environment.

By the way … I use the C++ client and not the Cocos2d C++ client as that one gave me issues with the libwebsockets lib that is included in my cocos setup (3.17). The C++ client worked out of the box on iOS. Mac and Linux (even though on iOS I also use OpenSSL).

Well for prosperity: I solved it by using the dynamic library.

I changed the .mk file of the client to:

LOCAL_PATH := $(call my-dir)

LIB_PATH := $(LOCAL_PATH)/../shared-libs/android/$(TARGET_ARCH_ABI)

include $(CLEAR_VARS)
LOCAL_MODULE := nakama-cpp
LOCAL_MODULE_FILENAME := libnakama-cpp
LOCAL_SRC_FILES := $(LIB_PATH)/$(LOCAL_MODULE_FILENAME).so
include $(PREBUILT_SHARED_LIBRARY)

And added the following to my app’s makefile:

LOCAL_SHARED_LIBRARIES := nakama-cpp

$(call import-add-path, $(LOCAL_PATH)/../../../nakama-cpp-sdk)
$(call import-module, nakama-cpp-android)