Libraries libOpenSLES and libOpenMAXAL depend on liblog but Android.mk
doesn't specify it. Native app links libOpenSLES or libOpenMAXAL
may fail with the following error message (taking
$NDK/samples/native-media as an example)
E/AndroidRuntime( 824): Caused by: java.lang.UnsatisfiedLinkError:
Cannot load library: link_image[2260]: 82 could not load needed
library 'libOpenMAXAL.so' for 'libnative-media-jni.so'
(mips_relocate_got[1804]: 82 In 'libOpenMAXAL.so',
can't locate symbol __android_log_assert)
The root cause is that both libOpenSLES.so and libOpenMAXAL.so depends on
liblog (containing the offending __android_log_assert) but Android makefile
doesn't specify it. The reason that linker doesn't complain about it
is because "--gc-sections" causes linker to "garbage-collect" which
removes unused (in this case "invisible") functions __assert/__assert2
in both shared libraries. Unfortunately, due to a bug (recently fixed
in 2.22.52 http://sourceware.org/bugzilla/show_bug.cgi?id=13811), linker
forgot to also remove references to dead function __android_log_assert
called in __assert/__assert2.
In theory this should affect all Android devices for native app linking
libOpenMAXAL.so or libOpenSLES.so, but it seems at this moment only MIPS-based
device is affected.
Fixed Android.mk to make it explicit.
bug: http://code.google.com/p/android/issues/detail?id=30179
related CL: https://android-review.googlesource.com/#/c/36302/
Change-Id: I61655a77d85f57cf103f9ac51505dc3d58f7c866
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS += -x c++ -DLI_API= -fvisibility=hidden -UNDEBUG \
-DSL_API='__attribute__((visibility("default")))'
-LOCAL_SHARED_LIBRARIES := libwilhelm
+LOCAL_SHARED_LIBRARIES := libwilhelm liblog
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS += -x c++ -DLI_API= -fvisibility=hidden -UNDEBUG \
-DXA_API='__attribute__((visibility("default")))'
-LOCAL_SHARED_LIBRARIES := libwilhelm
+LOCAL_SHARED_LIBRARIES := libwilhelm liblog
include $(BUILD_SHARED_LIBRARY)