简体   繁体   English

无法加载库libopencv_java.so

[英]Could Not Load Library libopencv_java.so

I'm currently facing a certain native compilation issue. 我目前正面临某个本地编译问题。 Just to be clear, I have done my opencv-ndk configuration with no error. 为了清楚起见,我已经完成了opencv-ndk配置而没有错误。 In fact, I have compiled and executed a few samples and tutorials from the source. 事实上,我已经从源代码编译并执行了一些示例和教程。 However, when I try to compile this, it gives me an error indicate I have lost something in my library. 但是,当我尝试编译它时,它给出了一个错误,表明我在我的库中丢失了一些东西。 Below is the log file from eclipse. 以下是eclipse的日志文件。 Notice, insides the eclipse project, I do have libopencv_java.so under obj->local->armeabi-v7a->objs directory. 注意,在eclipse项目中,我在obj-> local-> armeabi-v7a-> objs目录下有libopencv_java.so。

03-19 10:14:11.142: D/dalvikvm(6360): Trying to load lib /data/app-lib/com.example.detectimage-2/libnative_sample.so 0x4141bc60
03-19 10:14:11.152: E/dalvikvm(6360): dlopen("/data/app-lib/com.example.detectimage-2/libnative_sample.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libopencv_java.so" needed by "libnative_sample.so"; caused by load_library(linker.cpp:745): library "libopencv_java.so" not found
03-19 10:14:11.152: E/JNI(6360): WARNING: Could not load libmysharedlibrary.so
03-19 10:14:11.152: I/Sample::Activity(6360): Instantiated new class com.example.detectimage.DetectImageActivity
03-19 10:14:11.162: I/Sample::Activity(6360): onCreate
03-19 10:14:11.162: D/dalvikvm(6360): Trying to load lib /data/app-lib/com.example.detectimage-2/libnative_sample.so 0x4141bc60
03-19 10:14:11.162: E/dalvikvm(6360): dlopen("/data/app-lib/com.example.detectimage-2/libnative_sample.so") failed: Cannot load library: find_library(linker.cpp:889): "/data/app-lib/com.example.detectimage-2/libnative_sample.so" failed to load previously
03-19 10:14:11.162: W/dalvikvm(6360): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/example/detectimage/CameraPreview;
03-19 10:14:11.172: D/AndroidRuntime(6360): Shutting down VM
03-19 10:14:11.172: W/dalvikvm(6360): threadid=1: thread exiting with uncaught exception (group=0x40f06ae0)
03-19 10:14:11.182: E/AndroidRuntime(6360): FATAL EXCEPTION: main

In case you need my Android.mk file as well 如果您还需要我的Android.mk文件

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=off
include D:\Development\OpenCV-2.4.8-android-sdk\sdk\native\jni\OpenCV.mk

LOCAL_C_INCLUDES:= D:\Development\OpenCV-2.4.8-android-sdk\sdk\native\jni\include
LOCAL_MODULE    := native_sample
LOCAL_CFLAGS    := -Werror -O3 -ffast-math
LOCAL_LDLIBS    += -llog


LOCAL_SRC_FILES := jni_part.cpp
include $(BUILD_SHARED_LIBRARY)

Frankly, I have searched the entire resources, and have tried plenty of them, it just couldn't work. 坦率地说,我已经搜索了整个资源,并尝试了很多资源,它只是无法工作。 Perhaps I am new to this topic, certain advanced solution I wasn't able to follow to. 也许我是这个话题的新手,我无法遵循的某些先进的解决方案。 I wish I could get some better understanding here.Your help is so appreciated. 我希望我能在这里得到一些更好的理解。你的帮助非常感谢。

Looks like this is a runtime error and that you're able to build your native code without problems. 看起来这是一个运行时错误,您可以毫无问题地构建本机代码。 In order to include any necessary .so files in your .apk, you need to make them available in the lib/ subdirectory of the project yo want to deploy. 为了在.apk中包含任何必要的.so文件,您需要在要部署的项目的lib /子目录中使它们可用。

This can be as simple as copying them over manually, but ant should be smart enough to copy it over for you. 这可以像手动复制它们一样简单,但是ant应该足够聪明,可以为你复制它。 If it's not doing so, there's probably something else going on. 如果它没有这样做,可能还会有其他事情发生。

Another alternative is to link statically to OpenCV. 另一种方法是静态链接到OpenCV。 You can do this by adding this line before including OpenCV.mk in your own Android.mk: 您可以通过在自己的Android.mk中包含OpenCV.mk之前添加此行来执行此操作:

OPENCV_LIB_TYPE :=STATIC

This, of course, only make sense, if you're OpenCV build comes with static libraries (lib*.a). 当然,这只是有意义的,如果您的OpenCV构建带有静态库(lib * .a)。 You'll notice that by linking statically to OpenCV, your .so file will increase slightly in file size, but there won't be any need to package the libopencv_java.so anymore. 您会注意到,通过静态链接到OpenCV,您的.so文件将略微增加文件大小,但不再需要打包libopencv_java.so。 Your .so has everything it needs from OpenCV. 你的.so拥有OpenCV所需的一切。

To sum up, if your project uses any .so files, have them under /lib when the .apk gets packaged so that your application can find them at launch-/runtime. 总而言之,如果您的项目使用任何.so文件,请在.apk打包时将它们放在/ lib下,以便您的应用程序可以在启动/运行时找到它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Opencv Android:java.lang.UnsatisfiedLinkError:dlopen失败:无法加载库“libopencv_java.so” - Opencv Android: java.lang.UnsatisfiedLinkError: dlopen failed: could not load library “libopencv_java.so” UnsitisfiedLinkError:无法加载libopencv_java.so - UnsitisfiedLinkError: Couldn't load libopencv_java.so 找不到Android中的本机OpenCV UnsatisfiedLinkError libopencv_java.so - Native OpenCV in Android UnsatisfiedLinkError libopencv_java.so not found java.lang.UnsatisfiedLinkError:dlopen 失败:找不到库“libopencv_java3.so” - java.lang.UnsatisfiedLinkError: dlopen failed: library “libopencv_java3.so” not found Android Studio 出现 OpenCV 错误 dlopen 失败:找不到库“libopencv_java3415.so” - Android Studio with OpenCV error dlopen failed: library "libopencv_java3415.so" not found java.lang.UnsatisfiedLinkError:dlopen 失败:找不到库“../../lib/libopencv_core.so” - java.lang.UnsatisfiedLinkError: dlopen failed: library "../../lib/libopencv_core.so" not found 在qt pro文件中的libopencv_java3.so - libopencv_java3.so in qt pro file 无法加载库“ libdl.so.2” - could not load library “libdl.so.2” .apk保存此库时,libopencv_core.so出现UnsatisfiedLinkError - UnsatisfiedLinkError for libopencv_core.so while .apk holds this library 具有monodroid和emgu的UnsatisfiedLinkError-libopencv_highgui.so先前无法加载 - UnsatisfiedLinkError with monodroid and emgu - libopencv_highgui.so failed to load previously
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM