Android NDK: C ++ Runtime Limits When Using Out-of-the-Box Shared Libraries

I have a project that uses gnustl_static

C ++ runtime, which is globally set in Application.mk.

In a project, I would like to include a now pre-built shared library from a third party that implements some functionality. To do this, I use the mechanism PREBUILT_SHARED_LIBRARY

that the NDK build system provides:

include $(CLEAR_VARS)
LOCAL_MODULE := xyzAPI
LOCAL_SRC_FILES := libxyz-api.so
include $(PREBUILT_SHARED_LIBRARY)

      

and then later use it in main Android.mk

LOCAL_SHARED_LIBRARIES += xyzAPI

      

From a third party, I know that libxyz-api.so was built using c++_shared

.

Question 1: Do I need to take care that my dependency library was built with a different version? If so, does this mean that I would have to move my entire project to c++_shared

?

Question 2: Since the xyzAPI dependency was built with the runtime c++_shared

, now I need to download c++_shared

on the Java side (i.e. System.loadLibrary("c++_shared");

)?

+3


source to share


1 answer


  • This is definitely a hot issue. Using different C ++ scripts in a project is not impossible, but difficult and dangerous.

  • Since jb-mr2 (API level 18), the system will do it for you (see https://code.google.com/p/android/issues/detail?id=34416 ). However, it is your responsibility to ensure that you have the appropriate .so file packaged in your APK, including all relevant ABI variants.



All in all, I think switching to C ++ _shared is easier than looking at all the possible crashes.

+3


source







All Articles