Reputation: 31
Heya, I'm having trouble building an ndk/jni shared library which I have developed. I am hoping to reuse the libjpeg which ships with the platform (/system/lib/libjpeg.so) however I cannot get it to link. When I build my shared library I get...
/home/blink/workspace_android2/HackBitmapJNI/jni/jnijpeg/JNIBmp.cpp:94: undefined reference to `jpeg_std_error(jpeg_error_mgr*)'
/home/blink/workspace_android2/HackBitmapJNI/jni/jnijpeg/JNIBmp.cpp:96: undefined reference to `jpeg_CreateDecompress(jpeg_decompress_struct*, int, unsigned int)'
/home/blink/workspace_android2/HackBitmapJNI/jni/jnijpeg/JNIBmp.cpp:98: undefined reference to `jpeg_stdio_src(jpeg_decompress_struct*, __sFILE*)'
/home/blink/workspace_android2/HackBitmapJNI/jni/jnijpeg/JNIBmp.cpp:100: undefined reference to `jpeg_read_header(jpeg_decompress_struct*, int)'
/home/blink/workspace_android2/HackBitmapJNI/jni/jnijpeg/JNIBmp.cpp:102: undefined reference to `jpeg_start_decompress(jpeg_decompress_struct*)'
/home/blink/workspace_android2/HackBitmapJNI/jni/jnijpeg/JNIBmp.cpp:124: undefined reference to `jpeg_read_scanlines(jpeg_decompress_struct*, unsigned char**, unsigned int)'
/home/blink/workspace_android2/HackBitmapJNI/jni/jnijpeg/JNIBmp.cpp:130: undefined reference to `jpeg_destroy_decompress(jpeg_decompress_struct*)'
collect2: ld returned 1 exit status
make: *** [/home/blink/workspace_android2/HackBitmapJNI/obj/local/armeabi/libjnijpeg.so] Error 1*
Which is essentially every symbol I would need to resolve out of libjpeg.so at runtime...
I have copied libjpeg.so off of my emulator and into my project directory under 'lib'. When I run 'arm-eabi-readelf -s' on that copy of libjpeg.so I can see all of the above symbols defined (I can't see method signatures.. just names.. is there a way to dump signatures/namespaces??)
My Android.mk is as follows...
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := /opt/android_src/dalvik/libnativehelper/include/nativehelper \
/opt/android_src/frameworks/base/include \
/opt/android_src/system/core/include \
/opt/android_src/dalvik/libnativehelper/include \
/opt/android_src/external/stlport/stlport \
/opt/android_src/external/jpeg \
/opt/android_src/bionic
LOCAL_LDFLAGS += -Llib
LOCAL_MODULE := jnijpeg
LOCAL_SRC_FILES := JNIBmp.cpp
LOCAL_LDLIBS := -lm -llog -ljpeg -landroid_runtime
include $(BUILD_SHARED_LIBRARY)
Thank you much for any help!
Upvotes: 3
Views: 6004
Reputation: 31
Try to use #include in this form:
extern "C" {
#include "jpeglib.h"
}
It worked for me.
Good luck!
Upvotes: 2
Reputation: 121
I was able to link against -ljpeg using the following:
LOCAL_LDLIBS := -L$(MYDROID)/out/target/product/generic/system/lib/ -ljpeg
Upvotes: 1