简体   繁体   中英

Opencv Android: java.lang.UnsatisfiedLinkError: dlopen failed: could not load library “libopencv_java.so”

UPDATES AT THE BOTTOM OF THE POST

I am trying to use OpenCV face recognizers on android and while i was able to wrap the c++ code i couldn't make it work on a Intel Atom avd. I'm not 100% sure but i think the cause of the error in the title is that i miss the libopencv_java.so in the /lib/x86 project directory.

Any thoughts why the lib is missing and how to get it work properly?

缺少lib86ncv_java.so for x86

My Android.mk looks like:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
OPENCV_LIB_TYPE:=SHARED
include /home/fat/Scaricati/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk

LOCAL_MODULE    := FaceDetectionPerformances
LOCAL_SRC_FILES := FaceDetectionPerformances.cpp
FILE_LIST_CPP := $(wildcard $(LOCAL_PATH)/*.cpp) # finds all cpp files
OPENCV_INSTALL_MODULES:=on


include $(BUILD_SHARED_LIBRARY)

While my Application.mk is

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

The ndk-build log is

    18:32:16 **** Auto Build of configuration Default for project FaceDetectionPerformances ****
/home/fat/android-ndk-r9d/ndk-build NDK_DEBUG=1 all 
Android NDK: WARNING:jni/Android.mk:FaceDetectionPerformances: non-system libraries in linker flags: -lopencv_java    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    
[x86] Gdbserver      : [x86-4.6] libs/x86/gdbserver
[x86] Gdbsetup       : libs/x86/gdb.setup
[armeabi] Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
[armeabi-v7a] Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
[armeabi-v7a] Gdbsetup       : libs/armeabi-v7a/gdb.setup
[x86] Compile++      : FaceDetectionPerformances <= FaceDetectionPerformances.cpp
[x86] SharedLibrary  : libFaceDetectionPerformances.so
[x86] Install        : libFaceDetectionPerformances.so => libs/x86/libFaceDetectionPerformances.so
[armeabi] Compile++ thumb: FaceDetectionPerformances <= FaceDetectionPerformances.cpp
[armeabi] SharedLibrary  : libFaceDetectionPerformances.so
[armeabi] Install        : libFaceDetectionPerformances.so => libs/armeabi/libFaceDetectionPerformances.so
[armeabi] Install        : libopencv_java.so => libs/armeabi/libopencv_java.so
[armeabi-v7a] Compile++ thumb: FaceDetectionPerformances <= FaceDetectionPerformances.cpp
[armeabi-v7a] SharedLibrary  : libFaceDetectionPerformances.so
/home/fat/android-ndk-r9d/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/fat/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libopencv_java.so
[armeabi-v7a] Install        : libFaceDetectionPerformances.so => libs/armeabi-v7a/libFaceDetectionPerformances.so
[armeabi-v7a] Install        : libopencv_java.so => libs/armeabi-v7a/libopencv_java.so

1

8:32:37 Build Finished (took 20s.952ms)

UPDATE 1 The opencvAndroidSdk package provides the shared library libopencv_java for the x86 arch, but ndk will not move it to the libs/x86 directory at build time, while it does for armeabi arch. I also tried to move it manually from /OpenCV-2.4.9-android-sdk/sdk/native/libs/x86/libopencv_java.so to the /libs/x86 project subdirectory, but when i build the project, ndk deletes the file.

After some research, i managed to solve my problem. Apparently the APP_PLATFORM android-8 is not compatible with x86 android-opencv libs. So i just targeted android-9 and it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM