Android调试OpenCV车牌识别时cmake报错:C/C++ debug|armeabi-v7a : CMake Error at G:/Android sdk/ndk/21.2.6472646

一位Android新手在尝试开发车牌识别应用时,使用了hyperlpr开源项目并遇到了CMake配置问题。在引入.so文件(如armeabi-v7a)后,编译时仍然报找不到对应文件的错误。build.gradle和CMakeLists.txt的配置被展示出来,但问题未解决。开发者已尝试升级NDK版本,但问题依旧存在。
摘要由CSDN通过智能技术生成

 报错如上

本人Android小白,没有c++/c的经验,最近需要搞一个车牌识别的app,用的是开源的hyperlpr项目,搞完其他的东西后,然后导入好cmake开始调试时,一直报这个错

我引入过其他的.so文件比如

'x86', 'x86_64', 'mips', 'mips64',但是说报错都找不到对应文件

我的build.gradle如下

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion '30.0.3'

    defaultConfig {
        applicationId "com.example.test21"
        minSdkVersion 25
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11"
//                cppFlags "-std=c++11 -frtti -fexceptions"
//                abiFilters 'armeabi-v7a'
                arguments '-DANDROID_STL=gnustl_static'
//                arguments '-DANDROID_STL=gnustl_shared'
//                        '-DANDROID_ABI=armeabi-v7a'
            }
        }



        ndk   {
            //选择要添加的对应 cpu 类型的 .so 库。

                abiFilters 'armeabi-v7a'


            // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
        }

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }


    sourceSets.main {
        jni.srcDirs = [] // This prevents the auto generation of Android.mk
        jniLibs.srcDirs = ['libs','src/main/cpp/opencv342/sdk/native/libs']
        //jniLibs.srcDirs =['src/main/libs','src/main/jniLibs']
    }



    externalNativeBuild {
        cmake {
            path 'src/main/cpp/CMakeLists.txt'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation project(path:':openCVLibrary346')
}

目前我使用的是ndk16,我试过升级nkd版本,但是没有用,求求大佬们指点一下

我的cmake如下

message(STATUS "OpenCV libraries: ${OpenCV_LIBS}")

#include_directories(/Users/mac02/Desktop/studiospace/test/PrjAnndroid/app/src/main/cpp/include)
#set(pathToOpenCv /Users/mac02/Downloads/OpenCV-android)
#配置加载native依赖
#include_directories(${pathToOpenCv}/sdk/native/jni/include)
#动态方式加载
#add_library( lib_opencv SHARED IMPORTED )
#引入libopencv_java3.so文件
#set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION /Users/mac02/Desktop/studiospace/test/PrjAnndroid/app/src/main/jniLibs/armeabi-v7a/libopencv_java3.so)


aux_source_directory(. SOURCES1)
aux_source_directory(./src SOURCES2)
list (APPEND SOURCES
     ${SOURCES1}
     ${SOURCES2}
)
message(STATUS "My sources: ${SOURCES}")
add_library( # Sets the name of the library.
             hyperlpr

             # Sets the library as a shared library.
             SHARED

    # Provides a relative path to your source file(s).
   ${SOURCES})


#target_link_libraries( hyperlpr lib_opencv)
target_link_libraries(hyperlpr jnigraphics ${OpenCV_LIBS})

#连接现成的第三方库
#set(INC_DIR /Users/mac02/Desktop/studiospace/test/PrjAnndroid/app/src/main/cpp/OpencvNative/include)
#set(LINK_DIR /Users/mac02/Desktop/studiospace/test/PrjAnndroid/app/src/main/cpp/OpencvNative/libs)
#include_directories(OpencvNative/jni/include)

#include_directories(${INC_DIR}) # 用${}引用变量
#link_directories(${LINK_DIR})

#aux_source_directory(./include SOURCES1)
#aux_source_directory(./src SOURCES2)
#list (APPEND SOURCES
#     ${SOURCES1}
#     ${SOURCES2}
#    javaWarpper.cpp
#)
#add_library( # Sets the name of the library.
#             hyperlpr

#            # Sets the library as a shared library.
#             SHARED

             # Provides a relative path to your source file(s).
#            ${SOURCES})
Execution failed for task ':app:externalNativeBuildDebug'. > Build command failed. Error while executing process D:\NDK\android-sdk-windows\cmake\3.22.1\bin\ninja.exe with arguments {-C E:\desktop\MyApplication\app\.cxx\cmake\debug\armeabi-v7a myapplication} ninja: Entering directory `E:\desktop\MyApplication\app\.cxx\cmake\debug\armeabi-v7a' [1/2] Building CXX object CMakeFiles/myapplication.dir/native-lib.cpp.o FAILED: CMakeFiles/myapplication.dir/native-lib.cpp.o D:\NDK\android-sdk-windows\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi24 --gcc-toolchain=D:/NDK/android-sdk-windows/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/NDK/android-sdk-windows/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Dmyapplication_EXPORTS -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/myapplication.dir/native-lib.cpp.o -MF CMakeFiles\myapplication.dir\native-lib.cpp.o.d -o CMakeFiles/myapplication.dir/native-lib.cpp.o -c E:/desktop/MyApplication/app/src/main/cpp/native-lib.cpp E:/desktop/MyApplication/app/src/main/cpp/native-lib.cpp:3:10: fatal error: 'opencv2/core.hpp' file not found #include <opencv2/core.hpp> ^~~~~~~~~~~~~~~~~~ 1 error generated. ninja: build stopped: subcommand failed. * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights.
05-26
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值