Opencv Android:java.lang.UnsatisfiedLinkError:dlopen失败:无法加载库“libopencv_java.so”

时间:2014-06-27 18:04:19

标签: java android opencv android-ndk java-native-interface

在帖子的底部更新

我正在尝试在Android上使用OpenCV面部识别器,虽然我能够包装c ++代码但我无法使其在Intel Atom avd上运行。我不是100%肯定,但我认为标题中错误的原因是我想念/ lib / x86项目目录中的libopencv_java.so。

有关为什么缺少lib以及如何使其正常工作的任何想法?

libopencv_java.so for x86 is missing

我的Android.mk看起来像:

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)

虽然我的Application.mk是

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

ndk-build日志是

    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建成(耗时20s.952ms)

更新1 opencvAndroidSdk包为x86 arch提供了共享库libopencv_java,但是ndk在构建时不会将它移动到libs / x86目录,而是为armeabi arch。我还尝试将它从/OpenCV-2.4.9-android-sdk/sdk/native/libs/x86/libopencv_java.so手动移动到/ libs / x86项目子目录,但是当我构建项目时,ndk删除文件

1 个答案:

答案 0 :(得分:3)

经过一番研究,我设法解决了我的问题。显然APP_PLATFORM android-8与x86 android-opencv libs不兼容。所以我只针对android-9并且它有效。