gpt4 book ai didi

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

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

我尝试使用 OpenCV 构建项目,我从官方网站下载了 OpenCV SDK 3.1,但是在构建过程中出现错误

/Users/Mario/Downloads/OpenCV-android-sdk/sdk/native/jni/include/opencv2/core/mat.inl.hpp
Error:(571) undefined reference to 'cv::fastFree(void*)'
Error:(663) undefined reference to 'cv::Mat::create(int, int const*, int)'
Error:(682) undefined reference to 'cv::Mat::deallocate()'

这是我的 gradle.build,我使用 gradle-experimental:0.4.0

apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"

defaultConfig.with {
applicationId = "pl.mariusz.opencv"
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}

task ndkBuild(type: Exec) {
commandLine '/Users/Mario/Library/Android/android-ndk-r10e/ndk-build', '-C', file('src/main').absolutePath
}

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
}
android.ndk {
moduleName = "source_file"

cppFlags.add("-std=c++11")
cppFlags.add("-fexceptions")
cppFlags.add("-I${file("/Users/Mario/Downloads/OpenCV-android-sdk/sdk/native/jni/include")}".toString())
cppFlags.add("-I${file("/Users/Mario/Downloads/OpenCV-android-sdk/sdk/native/jni/include/opencv")}".toString())

stl = "gnustl_static"//"gnustl_static"//"gnustl_shared"//"stlport_static"
}

android.sources {
main {
jni{
source{
srcDirs = []
}
}
jniLibs {
source {
srcDirs = ['src/main/Libs']
}

}
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}

安卓.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCVROOT:= /Users/Mario/Downloads/OpenCV-android-sdk
OPENCV_LIB_TYPE=STATIC
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk

LOCAL_SRC_FILES := source_file.cpp
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE := source_file

include $(BUILD_SHARED_LIBRARY)

和Application.mk

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-17

我尝试将它与共享的静态 STL 混合使用,但仍然出现同样的错误,我该如何解决?

[编辑]

libopencv

[解决方案]

它更像是妥协而不是真正的解决方案,但我将 gradle-experimental:0.4.0 改回 classpath 'com.android.tools.build:gradle:1.5.0' 并使用

添加文件 gradle.properties 到项目根目录
android.useDeprecatedNdk=true

最佳答案

您必须将 opencv 库添加到您的链接器。为此,您必须做两件事: 1. 添加库文件; 2.添加库目录。

尝试

LOCAL_LDLIBS += -llog -ldl -LlibPath -lopencv_calib3d -lopencv_core 

等等,以这种方式添加所有 opencv 库(或至少是您需要的库)。 -l 将自动采用文件名和后缀中的“lib”。-L 将告诉链接器在哪里可以找到库,因此请添加 opencv 库文件夹的绝对路径而不是 libPath。参见 how to mention path of libraries in Android.mk file or Application.mk file?

试一试并告诉我新的错误信息。

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

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