在Android的原生的UnsatisfiedLinkError OpenCV的libopencv_java.so未找到 [英] Native OpenCV in Android UnsatisfiedLinkError libopencv_java.so not found

查看:3011
本文介绍了在Android的原生的UnsatisfiedLinkError OpenCV的libopencv_java.so未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了类似的帖子,但没有给出了正确的答案。

I've seen similar posts but none were giving correct answers.

设置:

Linux Ubuntu 14.04
Android NDK r8e
Boost 1.53
OpenCV 2.4.9

在编译时我得到了这样的警告:

While compiling I got this warning:

Compile++ thumb  : usit <= wahet.cpp
SharedLibrary  : libusit.so
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /home/tassilo/android-ndks/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO jni/opencv/sdk/native/jni/../libs/armeabi-v7a/libopencv_java.so
Install        : libusit.so => libs/armeabi-v7a/libusit.so

我还没有想叫我的C ++ code,所有我做的是创造导致这个错误的库:

I am not yet trying to call my C++ code, all I am doing is creating the library which results in this error:

09-16 14:34:59.189: V/IRISREC(654): Native code library failed to load.
09-16 14:34:59.189: V/IRISREC(654): java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1936]:    36 could not load needed library 'libopencv_java.so' for 'libusit.so' (load_library[1091]: Library 'libopencv_java.so' not found)

下面是我的 Android.mk

LOCAL_PATH := $(call my-dir)
NDK_ROOT := /home/tassilo/android-ndks/android-ndk-r8e


include $(CLEAR_VARS)

include ./jni/opencv/sdk/native/jni/OpenCV.mk

LOCAL_MODULE           := usit
LOCAL_SRC_FILES        := wahet.cpp

LOCAL_C_INCLUDES:= ./jni/opencv/sdk/native/jni/include
LOCAL_CFLAGS += -I$(LOCAL_PATH)/boost/include/boost-1_53
LOCAL_LDLIBS += -L$(LOCAL_PATH)/boost/lib/ -lboost_system-gcc-mt-1_53 -lboost_regex-gcc-mt-1_53 -lboost_filesystem-gcc-mt-1_53 -lboost_date_time-gcc-mt-1_53 \
-L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi \
-lgnustl_static \
-L$(SYSROOT)/usr/lib -llog

include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_PLATFORM          := android-8
APP_ABI               := armeabi-v7a
APP_OPTIM             := debug
NDK_DEBUG             := 1

NDK_TOOLCHAIN_VERSION := 4.6
APP_STL               := gnustl_static
APP_CPPFLAGS          := -fexceptions -frtti

和库加载我的 MainAcitvity.java

static {
    try {
        System.loadLibrary("usit");
    } catch (UnsatisfiedLinkError e) {
        Log.v(TAG, "Native code library failed to load.\n" + e);
    } catch (Exception e) {
        Log.v(TAG, "Exception: " + e);
    }
}

因此​​,错误在我的第一个catch块抛出。
需要的库文件都是我的文件夹

So the error is thrown in my first catch block. The need library files are in my folder

./jni/opencv/sdk/native/libs/ -armeabi/ -armeabi-v7a etc.

因为好几天,我没有与周围所有这些东西..任何帮助AP preciated。

I am failing around with all this stuff since several days.. Any help is appreciated.

推荐答案

关于隐藏符号'__aeabi_atexit的的 opencv.org 建议使用<$ C回答 $ C> gnustl_shared 而不是 gnustl_static

Regarding hidden symbol '__aeabi_atexit', the answer at opencv.org suggests to use gnustl_shared instead of gnustl_static.

这适合我的opencv_java个人的经验,并意味着Java code必须相应改变:​​

This fit my personal experience with opencv_java, and means that the Java code must change accordingly:

static {
    try {
        System.loadLibrary("gnustl_shared"); // added
        System.loadLibrary("opencv_java");
        System.loadLibrary("usit");
    } catch (UnsatisfiedLinkError e) {
        Log.v(TAG, "Native code library failed to load.\n" + e);
    } catch (Exception e) {
        Log.v(TAG, "Exception: " + e);
    }
}

Android.mk

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

OPENCV_INSTALL_MODULES:=on
include ./jni/opencv/sdk/native/jni/OpenCV.mk

LOCAL_MODULE           := usit
LOCAL_SRC_FILES        := wahet.cpp

LOCAL_C_INCLUDES := \
  $(LOCAL_PATH)/opencv/sdk/native/jni/include \
  $(LOCAL_PATH)/boost/include/boost-1_53

LOCAL_LDLIBS += -L$(LOCAL_PATH)/boost/lib/ \
  -lboost_system-gcc-mt-1_53 \
  -lboost_regex-gcc-mt-1_53 \
  -lboost_filesystem-gcc-mt-1_53 \
  -lboost_date_time-gcc-mt-1_53 \
  -llog

include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_PLATFORM          := android-8
APP_ABI               := armeabi-v7a
APP_OPTIM             := debug
NDK_DEBUG             := 1

NDK_TOOLCHAIN_VERSION := 4.6
APP_STL               := gnustl_shared
APP_CPPFLAGS          := -fexceptions -frtti

这篇关于在Android的原生的UnsatisfiedLinkError OpenCV的libopencv_java.so未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆