Issue
I am doing a native Android application and I have this problem:
In my native code I want to use Siglib (a DSP library) but when i use a function of this library and i try to run the app, appears this error:
undefined reference to 'SDA_CorrelateLinear'
This is my simple code:
nativo.cpp
#include "nativo.h"
#include "Parameters.h"
#include <siglib.h>
#include <android/log.h>
using namespace std;
#define LOG_TAG "NATIVO"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
JNIEXPORT jlong JNICALL Java_com_sistoleaudiocapture_Processing_init_1variables(
JNIEnv *, jclass) {
long dir = (long) new Parameters();
return (dir);
}
JNIEXPORT jdouble JNICALL Java_com_sistoleaudiocapture_Processing_prueba_1nativa(
JNIEnv *, jclass, jlong retorno) {
#define INPUT_1_LENGTH 5L
#define INPUT_2_LENGTH 5L
SLData_t pSrc1[] = { 0.05, 0.1, 0.15, 0.2, 0.25 };
SLData_t pSrc2[] = { 1.0, 1.0, 1.0, 1.0, 1.0 };
#define RESULT_LENGTH ((SLArrayIndex_t)(INPUT_1_LENGTH + INPUT_2_LENGTH - 1))
SLData_t dest[RESULT_LENGTH ];
SDA_CorrelateLinear(pSrc1,pSrc2,dest,5,5,9);
//SDA_CorrelateLinear(pSrc1, pSrc2, dest, INPUT_1_LENGTH, INPUT_2_LENGTH,
// RESULT_LENGTH );
double m1;
int pos_m = 0;
double aux = 0, mayor = 0;
for (int i = 0; i < 9; i++) {
aux = dest[i];
if (aux > mayor) {
mayor = aux;
pos_m = i;
}
}
return (mayor);
}
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := nativo.cpp Parameters.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH) C:\Users\telo\Downloads\SigLibFree\siglib\include
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE := native_code
include $(BUILD_SHARED_LIBRARY)
and Application.mk
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi
APP_PLATFORM := android-8
How can i do to solve this problem? Is possible if this library not have a Android version like OpenCV for example?
Thanks
Solution
Apparently, you are including the header files from SigLib, but you're not linking with it.
So to answer your last question, no, you need an Android version of SigLib's library to be able to use it in Android. Apparently, they don't have one out of the box, but it might be possible to compile it yourself (it's probably not a trivial task, but they do claim they have "Highly Portable ANSI C Source").
If you manage to obtain or create a SigLib library for Android, you might want to consult this question to see how to include it in your project.
Answered By - PaF
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.