Android : Android shared library built on linux host doesn't link properly with library build on Windows host

on Monday, October 13, 2014


I am compiling a set of several C++ libraries to arm-v7a using the Android NDK on Windows. I am compiling using ndk-build, for the most part. However, one of the libraries I am using (let's call it libproblem.so) has a rather complex makefile, so I use the ajb-tools (https://subversion.assembla.com/svn/ajb-tools/trunk/android/android-cross/android-cross) to call the makefile to build just that library on Linux. Both of these use the same NDK version.


I've made a few changes to the defaults in the android-cross script, to match my Application.mk, including:



export ANDROID_GCCVER=${ANDROID_GCCVER-4.8}
export ANDROID_PLAT_API_VER=${ANDROID_PLAT_API_VER-10} #not sure what this does...
export ANDROID_PLAT_NDK_VER=${ANDROID_PLAT_NDK_VER-9} #gingerbread
export ANDROID_TUNE=${ANDROID_TUNE-"-mandroid $ANDROID_TUNE_THUMB -mthumb-interwork -Wno-psabi -fpic -funwind-tables -fstack-protector -march=armv7-a -finline-limit=64"}


This seems to work fine, and gives me a library whose output to file gives me this:



../obj/local/armeabi-v7a/libproblem.so: ELF 32-bit LSB shared object, ARM,
version 1 (SYSV), dynamically linked (uses shared libs), not stripped


I am then linking it with the other libraries using the following in my Makefile.mk.



include $(CLEAR_VARS)
LOCAL_MODULE := problem
LOCAL_SRC_FILES := $(JNI_PATH)/../libs/prebuilt/$(TARGET_ARCH_ABI)/libproblem.so
include $(PREBUILT_SHARED_LIBRARY)


However, this causes a linking error. The library that depends on libproblem fails to create a shared object, stating:



d:/Code/project/jni/SomeCode.cpp:191: error: undefined reference to 'Problem::Client::Client(std::shared_ptr<Problem::Data> const&)'


The function of course exists. If I run nm on the libproblem.so in MinGW, I see the function there (albeit mangled).


My only line of thought currently is that there is an issue using two different Host OSes. Because what is particularly strange, is that ndk-build links libproblem.so with the rest of my objects succesfully if I use linux as the host OS for running ndk-build. (Keep in mind both Linux and Windows have the same NDK version, NDKr10b, 32-bit target for 64-bit host).


Or have I missed something in the android-cross script that is building that library in a way that's incompatible with my version of ndk-build?


0 comments:

Post a Comment