重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

win10下cmake编译Androidopencv库问题

win10下cmake编译opencv库问题

创新互联公司是一家集网站建设,黟县企业网站建设,黟县品牌网站建设,网站定制,黟县网站建设报价,网络营销,网络优化,黟县网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

1.未配置Android NDK工具链目录

CMake Error at platforms/android/android.toolchain.cmake:451 (message):
Could not find neither Android NDK nor Android standalone toolchain.

You should either set an environment variable:
export ANDROID_NDK=~/my-android-ndk

根据提示配置ANDROID_NDK到环境变量PATH中,即可
例如:ANDROID_NDK = D:\android-ndk-r14b


2.ndk版本不匹配。

CMake Error at cmake/OpenCVUtils.cmake:235 (TRY_COMPILE):
Failed to configure test project build system.
Call Stack (most recent call first):
cmake/OpenCVUtils.cmake:296 (ocv_check_compiler_flag)
cmake/OpenCVCompilerOptions.cmake:69 (ocv_check_flag_support)
cmake/OpenCVCompilerOptions.cmake:93 (add_extra_compiler_option)
CMakeLists.txt:495 (include)

发现这个问题时,先是使用Android Studio中链接下载的最新ndk目录(版本是17)。会报错
之后,从https://developer.android.google.cn/ndk/downloads/ 中下载最新的16b,还是报错。

最后 查看源码文件夹下opencv-3.2.0\platforms\android\android.toolchain.cmake文件里有两行注释

Android CMake toolchain file, for use with the Android NDK r5-r10d
Requires cmake 2.6.3 or newer (2.8.9 or newer is recommended).

提示使用r5到r10版本的NDK(我去网上下只剩r10e的,下载来编译后就可以通过了。)


3.下载依赖文件超时,未下载成功。比对hash码不匹配

CMake Error at D:/opencv/opencv-3.2.0/cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD HASH mismatch

for file: [D:/opencv/opencv_contrib-3.2.0/modules/dnn/.download/bd5e3eed635a8d32e2b99658633815ef/v3.1.0/protobuf-cpp-3.1.0.tar.gz]
  expected hash: [bd5e3eed635a8d32e2b99658633815ef]
    actual hash: [d41d8cd98f00b204e9800998ecf8427e]
         status: [28;"Timeout was reached"]

Call Stack (most recent call first):
D:/opencv/opencv_contrib-3.2.0/modules/dnn/cmake/download_protobuf.cmake:23 (ocv_download)
D:/opencv/opencv_contrib-3.2.0/modules/dnn/cmake/download_protobuf.cmake:51 (ocv_protobuf_download)
D:/opencv/opencv_contrib-3.2.0/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:30 (include)
D:/opencv/opencv_contrib-3.2.0/modules/dnn/CMakeLists.txt:35 (include)

CMake Error at D:/opencv/opencv-3.2.0/cmake/OpenCVUtils.cmake:1047 (message):
Failed to download v3.1.0/protobuf-cpp-3.1.0.tar.gz. Status=28;"Timeout
was reached"
Call Stack (most recent call first):
D:/opencv/opencv_contrib-3.2.0/modules/dnn/cmake/download_protobuf.cmake:23 (ocv_download)
D:/opencv/opencv_contrib-3.2.0/modules/dnn/cmake/download_protobuf.cmake:51 (ocv_protobuf_download)
D:/opencv/opencv_contrib-3.2.0/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:30 (include)
D:/opencv/opencv_contrib-3.2.0/modules/dnn/CMakeLists.txt:35 (include)

根据提示D:/opencv/opencv_contrib-3.2.0/modules/dnn/cmake/download_protobuf.cmake:23
找到该行信息
可以看出,他需要libprotobuf这个库,并且需要下载到 ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/protobuf/sources 目录下,而下载地址就是 https://github.com/google/protobuf/releases ,于是我们只要手动下载3.1.0,然后把文件放到这个目录下即可。

网页题目:win10下cmake编译Androidopencv库问题
网站URL:http://cqcxhl.com/article/jdecso.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP