Android NDK/JNI UnsatisfiedLinkError With .So library - android

I'm new to Android NDK, and I'm currently trying to build a RTMP C client for Android (and later iOS). Currently, I'm running into an issue where the application crashes as soon as I try to load my library:
static {
System.loadLibrary("test");
}
The exception I get is
java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "librtmp.so.1" needed by "libtest.so"; caused by library "librtmp.so.1" not found
I'm honestly completely lost. ndk-build doesn't return any errors:
[armeabi] Prebuilt : rtmp.so <= jni/rtmp/
[armeabi] Install : rtmp.so => libs/armeabi/rtmp.so
[armeabi] Compile thumb : test <= RTMPClient.c
[armeabi] SharedLibrary : libtest.so
[armeabi] Install : libtest.so => libs/armeabi/libtest.so
I've tried loading in the rtmp librarary via System.loadLibrary("rtmp"), but no dice.
Android.mk
LOCAL_PATH:= $(call my-dir)
LIBS_PATH := libs/$(TARGET_ARCH_ABI)
include $(CLEAR_VARS)
LOCAL_MODULE := rtmp
LOCAL_SRC_FILES := rtmp/rtmp.so
LOCAL_C_INCLUDES := rtmp/
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := RTMPClient.c
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES += rtmp
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_PLATFORM:=android-19
My RTMPClient.c uses some structs and functions from rtmp like so:
#include <rtmp/rtmp.h>
I'm not sure where librtmp.so.1 is coming from, but I also found it in my libtest.so with arm-linux-andrioideabi-readelf:
0x00000001 (NEEDED) Shared library: [librtmp.so.1]
Any ideas on how I can fix this?
EDIT: I got the rtmp.so file from here. I was sent there from the KODI librtmp update page

I ended up throwing out my rtmp.so file, and instead grabbed the jni files from rtmpdump-android. After putting those file in, changing my android.mk file to:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES += \
librtmp/amf.c \
librtmp/hashswf.c \
librtmp/log.c \
librtmp/parseurl.c \
librtmp/rtmp.c
LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS -DNO_CRYPTO
LOCAL_LDLIBS := -llog
LOCAL_MODULE := librtmp
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := dump
LOCAL_CFLAGS := -DRTMPDUMP_VERSION=\"v2.4\"
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := dump/rtmpdump.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../librtmp
LOCAL_C_INCLUDES += dump/rtmpdump.h
LOCAL_STATIC_LIBRARIES := librtmp
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := nelly.c nelly_tables.c RTMPClient.c
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES += dump
include $(BUILD_SHARED_LIBRARY)
And changing my RTMPClient.c file to include #include "librtmp/rtmp.h" instead of #include <rtmp/rtmp.h>, the file compiled and ran on my device without any issues.

Related

Adding Tesseract and Opencv to Android.mk (Android Studio)

I followed the instructions from here and added OpenCV successfully. But I've been trying to add tesseract to the Android.mk as well, for a few days now, and haven't been able to do it.
I have an android.cpp that uses tesseract so I have to include the dependency in my Android.mk . I found this post that had almost the exact problem and he solved it importing libtess.so and liblept.so files into Android.mk, but didn't explain how to do that, so I looked and found this post that shows how to link prebuilt libraries. So based on that I tried this Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := liblept
LOCAL_SRC_FILES := ../libs/$(TARGET_ARCH_ABI)/liblept.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../tess-two/jni
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libtess
LOCAL_SRC_FILES := ../libs/$(TARGET_ARCH_ABI)/libtess.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../tess-two/jni
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
OPENCV_PACKAGE_DIR:= /Users/danielsierraf/Documents/OpenCV-2.4.10-android-sdk/sdk
OPENCV_CAMERA_MODULES := off
include $(OPENCV_PACKAGE_DIR)/native/jni/OpenCV.mk
LOCAL_MODULE := run_detection
LOCAL_SHARED_LIBRARIES := libtess
LOCAL_SRC_FILES := text_detect.cpp android.cpp
LOCAL_LDLIBS += -landroid -llog -ldl
include $(BUILD_SHARED_LIBRARY)
And got this output:
[armeabi-v7a] Prebuilt : liblept.so <= src/main/jni/../libs/armeabi-v7a/
[armeabi-v7a] Install : liblept.so => src/main/jniLibs/armeabi-v7a/liblept.so
[armeabi-v7a] Compile++ thumb: run_detection <= text_detect.cpp
In file included from src/main/jni/text_detect.h:4:0,
from src/main/jni/text_detect.cpp:10:
src/main/jni/../../../../tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.h:32:22: fatal error: platform.h: No such file or directory
#include "platform.h"
^
compilation terminated.
So I guess is not linking libtess correctly, and if you look closely, it doesn't ever install libtess.so, it looks like it installs liblept.so, and then jumps to text_detect.cpp, ignoring this part:
include $(CLEAR_VARS)
LOCAL_MODULE := libtess
LOCAL_SRC_FILES := ../libs/$(TARGET_ARCH_ABI)/libtess.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../tess-two/jni
include $(PREBUILT_SHARED_LIBRARY)
So I tried to force it to install liblept and libtess completely before proceeding by putting it in different files. So I put the last part of the file in a different Android.mk in another folder and tried include $(call all-subdir-makefiles), and then it installs libtess and liblept completely, but ignores the call all-subdir-makefiles.
new jni folder structure:
Android.mk
Application.mk
text_detect/
Android.mk
android.cpp
text_detect.cpp
text_detect.h
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := liblept
LOCAL_SRC_FILES := ../libs/$(TARGET_ARCH_ABI)/liblept.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../tess-two/jni
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libtess
LOCAL_SRC_FILES := ../libs/$(TARGET_ARCH_ABI)/libtess.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../tess-two/jni
include $(PREBUILT_SHARED_LIBRARY)
include $(call all-subdir-makefiles)
textdetect/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_PACKAGE_DIR:= /Users/danielsierraf/Documents/OpenCV-2.4.10-android-sdk/sdk
OPENCV_CAMERA_MODULES := off
include $(OPENCV_PACKAGE_DIR)/native/jni/OpenCV.mk
LOCAL_MODULE := run_detection
LOCAL_SHARED_LIBRARIES := libtess
LOCAL_SRC_FILES := text_detect.cpp android.cpp
LOCAL_LDLIBS += -landroid -llog -ldl
include $(BUILD_SHARED_LIBRARY)
And this is the output:
[armeabi-v7a] Prebuilt : liblept.so <= src/main/jni/../libs/armeabi-v7a/
[armeabi-v7a] Install : liblept.so => src/main/jniLibs/armeabi-v7a/liblept.so
[armeabi-v7a] Prebuilt : libtess.so <= src/main/jni/../libs/armeabi-v7a/
[armeabi-v7a] Install : libtess.so => src/main/jniLibs/armeabi-v7a/libtess.so
[armeabi] Prebuilt : liblept.so <= src/main/jni/../libs/armeabi/
[armeabi] Install : liblept.so => src/main/jniLibs/armeabi/liblept.so
[armeabi] Prebuilt : libtess.so <= src/main/jni/../libs/armeabi/
[armeabi] Install : libtess.so => src/main/jniLibs/armeabi/libtess.so
[mips] Prebuilt : liblept.so <= src/main/jni/../libs/mips/
[mips] Install : liblept.so => src/main/jniLibs/mips/liblept.so
[mips] Prebuilt : libtess.so <= src/main/jni/../libs/mips/
[mips] Install : libtess.so => src/main/jniLibs/mips/libtess.so
[x86] Prebuilt : liblept.so <= src/main/jni/../libs/x86/
[x86] Install : liblept.so => src/main/jniLibs/x86/liblept.so
[x86] Prebuilt : libtess.so <= src/main/jni/../libs/x86/
[x86] Install : libtess.so => src/main/jniLibs/x86/libtess.so
As you see it installs everything from the first Android.mk perfectly, but it never runs textdetect/Android.mk
So, what I'm I doing wrong? How can I achieve this task that seems so simple? Is there an easier way?
EDIT:
After #ph0b response I went back to my first setup and added the same LOCAL_EXPORT_C_INCLUDES as the original Makefiles (with a couple of variations adapting it to my paths), and that solved it. It couldn't find platform.h because it didn't know where to look for it.
Now, after I did this change I had a different error No such file or directory #include "com_googlecode_tesseract_android/src/api/baseapi.h" and I thought this was because it didn't compile tesseract before run_detection that depends on it. Well that wasn't the problem, it still compiles run_detection before tesseract but that wasn't the issue, it was so much simpler and I feel so stupid for having spent so much time on this error. The problem was it didn't find com_googlecode_tesseract_android/src/api/baseapi.h because I didn't provide the path for that either, so I copied com_googlecode_tesseract_android and com_googlecode_leptonica_android from tess-two and added $(LOCAL_PATH) to LOCAL_EXPORT_C_INCLUDES. This is my final solution:
jni folder structure:
Android.mk
Application.mk
text_detect.cpp
android.cpp
text_detect.h
com_googlecode_leptonica_android
com_googlecode_tesseract_android
Android.mk
LOCAL_PATH := $(call my-dir)
#leptonica
LEPTONICA_LOCAL := $(LOCAL_PATH)/com_googlecode_leptonica_android
LEPTONICA_PATH := $(LEPTONICA_LOCAL)/src
include $(CLEAR_VARS)
LOCAL_MODULE := liblept
LOCAL_SRC_FILES := ../libs/$(TARGET_ARCH_ABI)/liblept.so
LOCAL_EXPORT_C_INCLUDES := \
$(LEPTONICA_LOCAL) \
$(LEPTONICA_PATH)/src
include $(PREBUILT_SHARED_LIBRARY)
#tesseract
TESSERACT_LOCAL := $(LOCAL_PATH)/com_googlecode_tesseract_android
TESSERACT_PATH := $(TESSERACT_LOCAL)/src
include $(CLEAR_VARS)
LOCAL_MODULE := libtess
LOCAL_SRC_FILES := ../libs/$(TARGET_ARCH_ABI)/libtess.so
LOCAL_EXPORT_C_INCLUDES := \
$(LOCAL_PATH) \
$(TESSERACT_PATH)/api \
$(TESSERACT_PATH)/ccmain \
$(TESSERACT_PATH)/ccstruct \
$(TESSERACT_PATH)/ccutil \
$(TESSERACT_PATH)/classify \
$(TESSERACT_PATH)/cube \
$(TESSERACT_PATH)/cutil \
$(TESSERACT_PATH)/dict \
$(TESSERACT_PATH)/opencl \
$(TESSERACT_PATH)/neural_networks/runtime \
$(TESSERACT_PATH)/textord \
$(TESSERACT_PATH)/viewer \
$(TESSERACT_PATH)/wordrec \
$(LEPTONICA_PATH)/src \
$(TESSERACT_LOCAL)
LOCAL_SHARED_LIBRARIES := liblept
include $(PREBUILT_SHARED_LIBRARY)
#opencv
include $(CLEAR_VARS)
OPENCV_PACKAGE_DIR:= /Users/danielsierraf/Documents/OpenCV-2.4.10-android-sdk/sdk
OPENCV_CAMERA_MODULES := off
include $(OPENCV_PACKAGE_DIR)/native/jni/OpenCV.mk
LOCAL_MODULE := run_detection
LOCAL_SRC_FILES := text_detect.cpp android.cpp
LOCAL_LDLIBS += -landroid -llog -ldl
LOCAL_SHARED_LIBRARIES += libtess liblept
include $(BUILD_SHARED_LIBRARY)
Your latest setup is failing in a weird way, ndk-build should at least try to compile your module. Maybe there is a bug in all-subdir-makefiles when there are ndk modules defined before it, and it doesn't find your module's Android.mk. You can try having only include $(call all-subdir-makefiles) inside your top level Android.mk.
Anyway, I think you should go back to your first setup, with your module directly in the jni root folder. Then, your main issue is the proper declaration of includes paths. tess-two/jni doesn't contain any headers ? They're in tess-two/jni/com_googlecode_*_android/src/*. That means you need to list these in your module declarations, by giving all the absolute paths to LOCAL_EXPORT_C_INCLUDES variables (like from the original Makefiles: https://github.com/rmtheis/tess-two/blob/master/tess-two/jni/com_googlecode_tesseract_android/Android.mk#L33)
You also need to add the dependency on liblept for libtess: LOCAL_SHARED_LIBRARIES := liblept inside libtess library declaration.
If it still fails, there is also another possibility: instead of redefining libtess and liblept modules using the generated .so files, you can directly include tess-two/jni/Android.mk and use the same Application.mk than tess-two (copy `tess-two/jni/Application.mk). It will already properly define libtess and liblept modules.

Android, NDK, prebuilt '.o' file is deleted by the build system

I am trying to link my exe w/ a pre-built '.o' object file ( consisting of a binary resource ).
the object file is located under '$(LOCAL_PATH)/dependency'.
Using a FileSys monitor, I can see that during compilation the Build system deletes the pre-built '.o' file.
using 'LOCAL_OBJECTS += 'dependency/prebuilt.o' doesn't help.
How can I prevent Android build system from deleting my pre-built '.o' file ?
A snap of the makefile used
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyTestApp
LOCAL_SRC_FILES := main.cpp
LOCAL_C_INCLUDES :=
LOCAL_LDLIBS := -llog
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_LDFLAGS := -Wl,--format=binary -Wl,Resources/MyBinRsrc -Wl,--output=dependency/MyBinRsrc.o -Wl,--format=elf,dependency/MyBinRsrc.o -Wl,--format=default
COMMON_SRC_FILES := $(LOCAL_SRC_FILES)
LOCAL_OBJECTS += dependency/MyBinRsrc.o
include $(BUILD_EXECUTABLE)

include libjpeg in a NDK build

As specified in this answer, I downloaded libjpeg 8d from github and placed it in a folder {ANDROID_APP}/jni/libjpeg. This library has it's own Android.mk, so I tried to include it at the end of my {ANDROID_APP}/jni/Android.mk this way :
include $(LOCAL_PATH)/libjpeg/Android.mk
Note : I'm using the latest version of android NDK (r8c)
After running ndk-build, I still get this error :
ANDROID_APP/jni/libfoo/foo_analysis.c:36:21: fatal error: jpeglib.h: No such file or directory
This is the structure of my global Android.mk :
LOCAL_PATH := $(call my-dir)
# libFoo
include $(CLEAR_VARS)
LOCAL_MODULE := libfoo
LOCAL_MODULE_FILENAME := libfoo
LOCAL_SRC_FILES := libfoo/foo.c libfoo/foo_analysis.c libfoo/foo_extract.c
LOCAL_STATIC_LIBRARIES := libbmp # declared previously but not shown in this example
LOCAL_CFLAGS = ${FLAGS}
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libfoo
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_STATIC_LIBRARY)
# libBar
include $(CLEAR_VARS)
LOCAL_MODULE := libbar
LOCAL_MODULE_FILENAME := libbar
LOCAL_SRC_FILES := bar/bar.c
LOCAL_STATIC_LIBRARIES := libfoo
LOCAL_CFLAGS = ${FLAGS}
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/bar
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_STATIC_LIBRARY)
# callbar
LOCAL_MODULE := libcallbar
LOCAL_MODULE_FILENAME := libcallbar
LOCAL_SRC_FILES := com_androidapp_nativeC_callbar.c
LOCAL_STATIC_LIBRARIES := libbar
LOCAL_CFLAGS = ${FLAGS}
include $(BUILD_SHARED_LIBRARY)
#libjpeg
include $(LOCAL_PATH)/libjpeg/Android.mk
I tried to use LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libfoo $(LOCAL_PATH)/libjpeg
and LOCAL_C_INCLUDES := $(LOCAL_PATH)/libjpeg in the libFoo module, but I still get the same error.
Just looked at Android.mk in jpeg8d-master folder and seems to be it has nothing.
I was trying to compile library directly according to STANDALONE-TOOLCHAIN.HTML
I do next: $export NDKROOT=/home/alex/tools/android-ndk-r8c (where is your NDK) $export SYSROOT=$NDKROOT/platforms/android-9/arch-arm (or any other android platform)
but files from jpeg8d-master have windows \r symbols and I deleted config.guess, config.sub, depcomp than use $automake -a command. And replace ltmain.sh from glib-2.34.0
than $./configure CC="$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT" --host=arm-linux-androideabi $make
next try prebuilts feature NDK - How to use a generated .so library in another project and NDK/PREBUILTS.HTML

ndk-build "member ... in archive is not an object"

I use this AES library (in C language),
http://gladman.plushost.co.uk/oldsite/AES/aes-src-16-04-07.zip
I follow this page and use the commds mentioned to compile libaes.a,
http://forums.devshed.com/c-programming-42/aes-encrypt-decrypt-in-c-687368.html
gcc -c -O2 -fomit-frame-pointer aescrypt.c aeskey.c aestab.c aes_modes.c
ar rcs libaes.a *.o
I can compile and run my program using the libaes.a without problem.
However if use ndk-build to compile my program (indeed modified a little),
I always get this error message and fail to compile...
"...member aes_modes.o in archive is not an object..."
what's wrong with that file?
Or what's wrong with the process?
my Android.mk :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libaes
LOCAL_SRC_FILES := libaes.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
LOCAL_C_INCLUDES :=\
/android-ndk-r6b/platforms/android-8/arch-arm/usr/include\
/android-ndk-r6b/samples/hello-jni/jni/libaes
LOCAL_WHOLE_STATIC_LIBRARIES := libaes
include $(BUILD_SHARED_LIBRARY)
I've a feeling that you compiled aes with native tools (x86) and using it as prebuild library. I've tried this Android.mk and it works:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := aes
LOCAL_SRC_FILES := aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := jni/aes
LOCAL_STATIC_LIBRARIES := aes
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
include $(BUILD_SHARED_LIBRARY)
Just unzip aes-src-16-04-07.zip into jni/aes. I think it is better to use ndk build system because it can set all necesary options.
And hello-jni.c (just in case):
#include <aes.h>
void test() {
aes_init();
}

Android NDK, two Static Libraries and Linking

I started off creating libraries as shared libraries, but I considered it would be more efficient to create one shared libraries and the rest static. When it was all shared, it compiled and linked fine, but moving to static, I get on linking "undefined reference".
Edit: I build all the libraries in one Android.mk
Android.mk:
MY_LOCAL_PATH := $(call my-dir)
MY_LOCAL_CFLAGS := -DDEBUG
TARGET_PLATFORM := 'android-4'
LOCAL_PATH := $(MY_LOCAL_PATH)/../../Base
include $(CLEAR_VARS)
LOCAL_MODULE := Base
LOCAL_SRC_FILES := <Base src files>
include $(BUILD_STATIC_LIBRARY)
MY_LOCAL_STATIC_LIBRARIES := Base
MY_LOCAL_C_INCLUDES := $(MY_LOCAL_PATH)/../../Base
LOCAL_PATH := $(MY_LOCAL_PATH)/../../Framework
include $(CLEAR_VARS)
LOCAL_MODULE := Framework
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := <Framework src files>
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
include $(BUILD_STATIC_LIBRARY)
MY_LOCAL_STATIC_LIBRARIES += Framework
MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/../../Framework
LOCAL_PATH := $(MY_LOCAL_PATH)/Graphics
include $(CLEAR_VARS)
LOCAL_MODULE := Graphics
LOCAL_SRC_FILES := <Graphics src files>
LOCAL_EXPORT_LDLIBS := -lGLESv1_CM
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)
MY_LOCAL_STATIC_LIBRARIES += Graphics
MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/Graphics
LOCAL_PATH := $(MY_LOCAL_PATH)/Platform
include $(CLEAR_VARS)
LOCAL_MODULE := Platform
LOCAL_SRC_FILES := <Platform src files>
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)
MY_LOCAL_STATIC_LIBRARIES += Platform
MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/Platform
LOCAL_PATH := $(MY_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := Final
LOCAL_SRC_FILES := <Final src files>
LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES)
LOCAL_LDLIBS := -llog
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
include $(BUILD_SHARED_LIBRARY)
Last line of ndk-build V=1 -B:
SharedLibrary : libFinal.so
/Users/robbie/Library/Frameworks/Android-NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ -Wl,-soname,libFinal.so -shared --sysroot=/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm <object files> /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libBase.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libFramework.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libGraphics.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libPlatform.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libstdc++.a /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libc.so /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libstdc++.so /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libm.so -Wl,--no-undefined -Wl,-z,noexecstack -L/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib -llog -lGLESv1_CM -lstdc++ -Wl,-rpath-link=/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib -lsupc++ -o /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libFinal.so
/Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libPlatform.a(ATexture.o): In function `ATexture':
/Users/robbie/Documents/Apps/Revolution/Android/jni/SpinTap/ATexture.cpp:9: undefined reference to `TextureRenderer::TextureRenderer(unsigned int)'
/Users/robbie/Documents/Apps/Revolution/Android/jni/SpinTap/ATexture.cpp:9: undefined reference to `TextureRenderer::TextureRenderer(unsigned int)'
Edit2: TextureRenderer is in Graphics, which is included.
Does anyone have an idea why it may not be working and how to fix it?
This looks like an order-of-linking issue to me.
Your command line is:
arm-linux-androideabi-g++ -Wl,-soname,libFinal.so -shared \
libBase.a libFramework.a libGraphics.a libPlatform.a -o libFinal.so
and the error is
libPlatform.a(ATexture.o): In function `ATexture':
ATexture.cpp:9: undefined reference to `TextureRenderer'
ATexture.cpp:9: undefined reference to `TextureRenderer'
TextureRenderer is in Graphics. But libGraphics is before libPlatform on the command line. g++ will search each library on the command line in the order they are given, loading functions to resolve external references. It will read libGraphics once, load the functions that resolve external references and move on to libPlatform.
Try changing LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES) to LOCAL_STATIC_LIBRARIES := Platform Graphics Framework Base and see how you get on.
In your Android.mk, make sure you are referencing the static library with the proper call:
LOCAL_STATIC_LIBRARIES := mystaticlibproj
before calling include $(BUILD_SHARED_LIBRARY).
Then, at the end of the file, place the call to import the static lib module
$(call import-module, mystaticlibproj)
If you're still having trouble, post the verbose build log (ndk-build V=1 -B) and your Android.mk

Categories

Resources