2

我正在开发一个 JNI 代码的 Android 应用程序,这个代码使用 OpenCV 库。

JNI 代码的 .c 类是“ 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&)'
...

谢谢!

4

0 回答 0