gpt4 book ai didi

android - 对 `cv::fastFree(void*)' 的 undefined reference

转载 作者:太空宇宙 更新时间:2023-11-03 22:29:58 24 4
gpt4 key购买 nike

我有一个使用 OpenCVC++ (ImageExtraction.cpp) 文件。这是 C++ 文件的快照。我想从我的 Android java 文件中调用这个 native C++ 文件。我正在使用 Mac...

#include < string.h>       
#include < jni.h>
#include < opencv2/imgproc/imgproc.hpp>
#include < opencv2/highgui/highgui.hpp>
#include < iostream>
#include < cv.h>
#include < stdio.h>
#include < algorithm>
#include < functional>

using namespace cv;
using namespace std;

extern "C"
{
JNIEXPORT jint JNICALL Java_com_clematistech_businesscardreader_BusinessCardReader_stringFromJNI(JNIEnv *env, jobject obj)
{

........
}
}

这是我的 Android.mk:

LOCAL_PATH := $(call my-dir)

LOCAL_C_INCLUDES := /usr/local/include/opencv
include $(CLEAR_VARS)

include /Users/sritomamajumder/Documents/MISC/Softwares/OpenCV_for_Android/OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk

LOCAL_LDLIBS := -llog

LOCAL_MODULE := ImageExtraction
LOCAL_SRC_FILES := ImageExtraction.cpp

LOCAL_STATIC_LIBRARIES := libzip libpng libjpeg freetype
LOCAL_STATIC_LIBRARIES += libopencv_contrib libopencv_legacy libopencv_ml libopencv_stitching libopencv_nonfree libopencv_objdetect libopencv_videostab libopencv_calib3d libopencv_photo libopencv_video libopencv_features2d libopencv_highgui libopencv_androidcamera libopencv_flann libopencv_imgproc libopencv_ts libopencv_core
include $(BUILD_SHARED_LIBRARY)

这是 Application.mk:

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := all
APP_PLATFORM := android-10
APP_MODULES := ImageExtraction

当我从根 Android 项目运行 ndk-build 命令时,出现以下错误:

[arm64-v8a] Compile++      : ImageExtraction <= ImageExtraction.cpp
[arm64-v8a] SharedLibrary : libImageExtraction.so
./obj/local/arm64-v8a/objs/ImageExtraction/ImageExtraction.o: In function `cv::Mat::~Mat()':
/Users/sritomamajumder/Documents/MISC/Softwares/OpenCV_for_Android/OpenCV-2.4.10-android-sdk/sdk/native/jni/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
......

请让我知道我做错了什么。

最佳答案

将 APP_ABI 设置为 all,最新的 NDK 将设置为为所有 64 位平台(arm64-v8a、x86_64...)和 32 位平台编译您的代码。但是您的 OpenCV 包不包含 64 位平台的二进制文件,我想这就是您遇到当前问题的原因。

您可以在 Application.mk 文件中将 APP_ABI 设置为 all32 以仅针对 OpenCV 包提供预构建的 32 位平台(armeabi-v7a x86 armeabi mips)为。

关于android - 对 `cv::fastFree(void*)' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28191746/

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