include/opencv2/core/cvstd.hpp:647: undefined reference to `cv::String::deallocate()'

今天编译一个执行文件时发生了如下错误

/home/archermind/test/jni/include/opencv2/core/mat.inl.hpp:804: undefined reference to `cv::Mat::deallocate()'
/home/archermind/test/obj/local/arm64-v8a/objs/t/test.o: In function `~Mat':
/home/archermind/test/jni/include/opencv2/core/mat.inl.hpp:692: undefined reference to `cv::fastFree(void*)'
/home/archermind/test/obj/local/arm64-v8a/objs/t/test.o: In function `~String':
/home/archermind/test/jni/include/opencv2/core/cvstd.hpp:647: undefined reference to `cv::String::deallocate()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/archermind/test/obj/local/arm64-v8a/t] Error 1

archermind@flm:~/test/jni$ ls
Android.mk  Application.mk    include  libopencv_java3.so  test.cpp

这个时候就得检查一下include和libopencv_java*.so有没有问题

我这里用的是arm64-v8a,所以我就拷贝了一个这个目录下的libopencv_java3.so到当前路径,然后将当前的include文件夹删掉,重新从

包含这个libopencv_java3.so的sdk里面拷贝一份include放到了当前路径下,然后编译通过

下面附上我的Android.mk

LOCAL_PATH:= $(call my-dir)  
include $(CLEAR_VARS)  
NDK_APP_DST_DIR := $(LOCAL_PATH)
OPENCV_LIB_TYPE=STATIC
#include /home/archermind/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk 
LOCAL_SRC_FILES := test.cpp
LOCAL_CFLAGS := -D__cpusplus -g -mfloat-abi=softfp -mfpu=neon -march=armv8-a -mtune=cortex-a53
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_LDFLAGS += -L./
LOCAL_LDLIBS := -lz -llog -lopencv_java3
TARGET_ARCH_ABI :=arm64-v8a 
LOCAL_ARM_MODE := arm
ifeq ($(TARGET_ARCH_ABI),arm64-v8a) 
LOCAL_ARM_NEON := true 
endif   
LOCAL_MODULE := t     
include $(BUILD_EXECUTABLE)

你可能感兴趣的:(工具)