gpt4 book ai didi

android - NDK-build 不会创建 .so 文件

转载 作者:行者123 更新时间:2023-11-30 01:43:08 25 4
gpt4 key购买 nike

我正在尝试构建一个本地库,称为 receipetrecognizer,它是从 Android 应用程序调用的。

我认为我正确设置了所有内容,因为 NDK-build 没有显示任何错误。但是,当我调用 System.loadLibrary("receiptrecognizer"); 时,我得到一个 UnsatisfiedLinkError

这是因为没有libreceiptrecognizer.so文件在 apk 中。实际上没有 libreceiptrecognizer.so 文件当我运行 ndk-build 时在任何地方创建。

为什么没有生成.so文件?

receiptrecognizer 使用 openCV 和 tesseract(后者又使用 leptonica)。

这是我的 Android.mk:

    LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ../opencv4android/sdk/native/jni/OpenCV.mk

include $(CLEAR_VARS)
LOCAL_MODULE := lept
LOCAL_SRC_FILES := ../../tess-two/libs/$(TARGET_ARCH_ABI)/liblept.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := tess
LOCAL_SRC_FILES := ../../tess-two/libs/$(TARGET_ARCH_ABI)/libtess.so
include $(PREBUILT_SHARED_LIBRARY)


LOCAL_MODULE := receiptrecognizer

LOCAL_SRC_FILES := \
src/OCRImagePreprocessor.cpp \
src/util.cpp \
ocrimagepreprocessorjni.cpp

LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../opencv4android/sdk/native/jni/include \
$(LOCAL_PATH)/../../tess-two/jni/com_googlecode_leptonica_android/src/src \
$(LOCAL_PATH)/../../tess-two/jni/com_googlecode_tesseract_android/src \
$(LOCAL_PATH)/../../tess-two/jni/com_googlecode_tesseract_android/src/ccutil \
$(LOCAL_PATH)/../../tess-two/jni/com_googlecode_tesseract_android/src/ccstruct \
$(LOCAL_PATH)/../../tess-two/jni/com_googlecode_tesseract_android/src/ccmain \
$(LOCAL_PATH)/jni/src \
$(LOCAL_PATH)/jni \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)

LOCAL_CFLAGS := \
--std=c++11

LOCAL_SHARED_LIBRARIES := \
opencv_java3 \
lept \
tess

include $(BUILD_SHARED_LIBRARY)

下面是 ndk-build 的输出(除了一些关于覆盖目标命令的警告):

[armeabi] Prebuilt       : liblept.so <= jni/../../tess-two/libs/armeabi/
[armeabi] Install : liblept.so => libs/armeabi/liblept.so
[armeabi] Prebuilt : libopencv_java3.so <= ../opencv4android/sdk/native/jni/../libs/armeabi/
[armeabi] Install : libopencv_java3.so => libs/armeabi/libopencv_java3.so
[armeabi] Compile++ thumb: receiptrecognizer <= OCRImagePreprocessor.cpp
[armeabi] Compile++ thumb: receiptrecognizer <= util.cpp
[armeabi] Compile++ thumb: receiptrecognizer <= ocrimagepreprocessorjni.cpp
make.exe: Circular obj/local/armeabi/libtess.so <- obj/local/armeabi/libtess.so dependency dropped.
[armeabi] Prebuilt : libtess.so <= obj/local/armeabi/objs/receiptrecognizer/src/
[armeabi] Install : libtess.so => libs/armeabi/libtess.so
[armeabi-v7a] Prebuilt : liblept.so <= jni/../../tess-two/libs/armeabi-v7a/
[armeabi-v7a] Install : liblept.so => libs/armeabi-v7a/liblept.so
[armeabi-v7a] Prebuilt : libopencv_java3.so <= ../opencv4android/sdk/native/jni/../libs/armeabi-v7a/
[armeabi-v7a] Install : libopencv_java3.so => libs/armeabi-v7a/libopencv_java3.so
[armeabi-v7a] Compile++ thumb: receiptrecognizer <= OCRImagePreprocessor.cpp
[armeabi-v7a] Compile++ thumb: receiptrecognizer <= util.cpp
[armeabi-v7a] Compile++ thumb: receiptrecognizer <= ocrimagepreprocessorjni.cpp
make.exe: Circular obj/local/armeabi-v7a/libtess.so <- obj/local/armeabi-v7a/libtess.so dependency dropped.
[armeabi-v7a] Prebuilt : libtess.so <= obj/local/armeabi-v7a/objs/receiptrecognizer/src/
[armeabi-v7a] Install : libtess.so => libs/armeabi-v7a/libtess.so
[x86] Prebuilt : liblept.so <= jni/../../tess-two/libs/x86/
[x86] Install : liblept.so => libs/x86/liblept.so
[x86] Prebuilt : libopencv_java3.so <= ../opencv4android/sdk/native/jni/../libs/x86/
[x86] Install : libopencv_java3.so => libs/x86/libopencv_java3.so
[x86] Compile++ : receiptrecognizer <= OCRImagePreprocessor.cpp
[x86] Compile++ : receiptrecognizer <= util.cpp
[x86] Compile++ : receiptrecognizer <= ocrimagepreprocessorjni.cpp
make.exe: Circular obj/local/x86/libtess.so <- obj/local/x86/libtess.so dependency dropped.
[x86] Prebuilt : libtess.so <= obj/local/x86/objs/receiptrecognizer/src/
[x86] Install : libtess.so => libs/x86/libtess.so
[mips] Prebuilt : liblept.so <= jni/../../tess-two/libs/mips/
[mips] Install : liblept.so => libs/mips/liblept.so
[mips] Prebuilt : libopencv_java3.so <= ../opencv4android/sdk/native/jni/../libs/mips/
[mips] Install : libopencv_java3.so => libs/mips/libopencv_java3.so
[mips] Compile++ : receiptrecognizer <= OCRImagePreprocessor.cpp
[mips] Compile++ : receiptrecognizer <= util.cpp
[mips] Compile++ : receiptrecognizer <= ocrimagepreprocessorjni.cpp
make.exe: Circular obj/local/mips/libtess.so <- obj/local/mips/libtess.so dependency dropped.
[mips] Prebuilt : libtess.so <= obj/local/mips/objs/receiptrecognizer/src/
[mips] Install : libtess.so => libs/mips/libtess.so

欢迎任何想法。

最佳答案

在来自 ndk-build 的跟踪中你显示,我看到这一行make.exe: Circular obj/local/mips/libtess.so <- obj/local/mips/libtess.so dependency dropped.

我认为这就是为什么您没有正确的 .so生成的库。我想你忘了添加 include $(CLEAR_VARS)之前LOCAL_MODULE := receiptrecognizer .

希望对你有用。

关于android - NDK-build 不会创建 .so 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34152094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com