墨盒飞飞 2019-06-03 13:20 采纳率: 100%
浏览 1744
已采纳

opencv 在as ndk中 始终抱找不到 undefined reference to 'cv::imwrite

就这几行简单的代码编译都不通过

#include"opencv2/opencv.hpp"
using namespace cv;
    int sss()
{
    Mat image= imread( "1", CV_LOAD_IMAGE_COLOR);
    imwrite("2.bmp",image);
    return 1;
}

CMakeLists 文件

cmake_minimum_required(VERSION 3.4.1)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
set(CMAKE_VERBOSE_MAKEFILE on)
set(ocvlibs "C:\\BC\\OpenCV\\sdk\\native\\libs")
# 设置include文件夹的地址
include_directories(C:/BC/lua-5.2.0/src)
include_directories(C:\\BC\\OpenCV\\sdk\\native\\jni\\include)

add_library(native-lib SHARED native-lib.cpp)
# 设置opencv的动态库

add_library(libopencv_java SHARED IMPORTED )
set_target_properties(libopencv_java PROPERTIES IMPORTED_LOCATION "${ocvlibs}/${ANDROID_ABI}/libopencv_java3.so")

find_library(log-lib log)


target_link_libraries(native-lib android log libopencv_java ${log-lib} )

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.opencvtest"
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11", "-frtti", "-fexceptions"
                abiFilters 'x86'
            }
        }
    }
    sourceSets{
        main{
            jniLibs.srcDirs = ['C:\\BC\\OpenCV\\sdk\\native\\libs']
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

图片说明

  • 写回答

1条回答 默认 最新

  • 墨盒飞飞 2019-06-03 16:19
    关注

    老是自问自答很尴尬 ,解决了 ndk r14 opencv3.0

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)
  • ¥50 Qt在release捕获异常并跟踪堆栈(有Demo,跑一下环境再回答)
  • ¥30 python,LLM 文本提炼
  • ¥15 关于将inet引入的相关问题
  • ¥15 关于一个倒计时的操作和显示设计
  • ¥15 提问STK的问题,哪位航天领域的同学会啊
  • ¥15 苹果系统的mac m1芯片的笔记本使用ce修改器使用不了
  • ¥15 单相逆变的电压电流双闭环中进行低通滤波PID算法改进
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 如何卸载arcgis 10.1 data reviewer for desktop