I have successfully compiled the LibXtract library for the generic libxtract.so object and want to use it in the second project.
In the mention project, I'm trying to compile it into a simple function:
#include <com_androidnative1_NativeClass.h> #include <android/log.h> #include "libxtract.h" JNIEXPORT void JNICALL Java_com_androidnative1_NativeClass_showText (JNIEnv *env, jclass clazz) { float mean = 0, vector[] = {.1, .2, .3, .4, -.5, -.4, -.3, -.2, -.1}, spectrum[10]; int n, N = 9; float argf[4]; argf[0] = 8000.f; argf[1] = XTRACT_MAGNITUDE_SPECTRUM; argf[2] = 0.f; argf[3] = 0.f; xtract[XTRACT_MEAN]((void *)&vector, N, 0, (void *)&mean); __android_log_print(ANDROID_LOG_DEBUG, "LIbXtract", "Button pushe2"); }
I have a flat structure:
- JNI / com_androidnative1_NativeClass.c
- JNI / com_androidnative1_NativeClass.hjni / libxtract.h
- jni / other * .h files from the libxtract interface
- JNI / Android.mk
- JNI / Applicatoin.mk
libxtract.so library I put in the mainproject / lib folder
my Android.mk file looks like this:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := com_androidnative1_NativeClass.c LOCAL_MODULE := com_androidnative1_NativeClass LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ LOCAL_LDLIBS += -llog LOCAL_SHARE_LIBRARIES := libxtract NDK_MODULE_PATH += $(LOCAL_PATH)/../lib/ include $(BUILD_SHARED_LIBRARY)
and I still got the error:
Compile thumb : com_androidnative1_NativeClass <= com_androidnative1_NativeClass.c SharedLibrary : libcom_androidnative1_NativeClass.so./obj/local/armeabi/objs/com_androidnative1_NativeClass/com_androidnative1_Nativ eClass.o: In function `Java_com_androidnative1_NativeClass_showText': /home/jack/Projects/AndroidNative1/jni/com_androidnative1_NativeClass.c:20: undefined reference to `xtract' collect2: ld returned 1 exit status make: *** [obj/local/armeabi/libcom_androidnative1_NativeClass.so] Error 1
The code appeared in the form of a LibXtract example and under C ++ it compiles without problems, any ideas?