OpenCV,Android和JNI

时间:2013-05-10 17:06:48

标签: android opencv java-native-interface

我正在开发一个Android应用程序,其中JNI代码和此代码使用OpenCV库。

.c类的JNI代码是“ sintetica.c ”:

#include <jni.h>
#include "sintetica.h"

#include <opencv/cv.h>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/imgproc/types_c.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>

jint  Java_com_example_imagen3d_Imagen3DActivity_sintetica(JNIEnv *env, jobject thiz,jint argc, jchar *argv[]) {

...

    return 0;

}

Android.mk 文件:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

OPENCV_CAMERA_MODULES:=off
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=STATIC

include /home/vmg/workspace/android/OpenCV-2.4.5-android-sdk/sdk/native/jni/OpenCV.mk

LOCAL_MODULE :=sintetica
LOCAL_LDLIBS += -llog -ldl
LOCAL_SRC_FILES :=sintetica.c

include $(BUILD_SHARED_LIBRARY)

Application.mk 文件:

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a armeabi x86
APP_PLATFORM := android-8

Java类

![public class Imagen3DActivity  extends Activity {
       ...
    public native int Java_com_example_imagen3d_Imagen3DActivity_sintetica(int argc, char argv\[\]);   
    static {
        System.loadLibrary("sintetica");
    }  
}]

我是Linux用户,我正在使用Eclipse Juno和Opencv 2.4.5,虽然对于.c类我使用的是Linux存储库的OpenCV库,我不知道它是什么版本。

发生的部分错误如下:

20:10:55 **** Incremental Build of configuration Default for project Imagen3D ****
/home/vmg/android/android-ndk-r8c/ndk-build 
SharedLibrary  : libsintetica.so
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x86): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x94): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0xa4): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x11c): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x9c4): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0xb78): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x2058): error: undefined reference to '__cxa_end_cleanup'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x2146): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&)'
...

谢谢!

0 个答案:

没有答案