我有一个使用C++
的{{1}}(ImageExtraction.cpp
)文件。以下是OpenCV
文件的快照。我想从我的Android java文件中调用这个本机C ++文件。我正在使用Mac ...
C++
这是我的Android.mk:
#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)
{
........
}
}
这是Application.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)
当我从我的根Android项目运行ndk-build命令时,我收到以下错误:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := all
APP_PLATFORM := android-10
APP_MODULES := ImageExtraction
请让我知道我做错了什么。
答案 0 :(得分:2)
将APP_ABI设置为all,最新的NDK设置为编译所有64位平台(arm64-v8a,x86_64 ...)以及32位平台的代码。 但是你的OpenCV软件包并不包含64位平台的二进制文件,我想这就是你遇到当前问题的原因。
您可以在 Application.mk 文件中将APP_ABI设置为all32
,以仅定位OpenCV程序包为其提供预构建的32位平台(armeabi-v7a x86 armeabi mips)。 / p>