首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >的交叉编译OpenCV : Cmake配置过程中的错误

的交叉编译OpenCV : Cmake配置过程中的错误
EN

Stack Overflow用户
提问于 2022-03-20 10:52:42
回答 1查看 567关注 0票数 0

问题描述:

我试图用OpenCV支持在Ubuntu20.04LTSforAndroid (aarch64)上编译OpenCL 4.5.1 (因为股票OpenCV Android没有激活OpenCL支持)。我很大程度上追随了本教程涵盖OpenCV的交叉编译。

当试图配置构建时,Cmake似乎无法正确创建/定位所有必需的文件夹,从而引发一个错误(参见下面的cmake输出)。

我怀疑这可能与Cmake难以正确识别ant安装有关(如Cmake输出中ant路径后面缺少的版本号所示)。

我已经通过Cmake标志为ANT可执行文件和Java文件夹设置了环境变量(参见下面的Cmake命令)。

当查看Cmake输出底部的错误消息时,很明显,创建必要的Android和/或Java文件夹存在一些问题。在检查modules/java/android_sdk/CMakeLists.txt (请参阅下面的摘录)时,我注意到变量OPENCV_JAVA_DIR可能应该在cmake配置的早期阶段设置。但是,当运行粘贴在下面的命令时,这个变量仍然是空的,因此cmake无法访问文件夹,因为路径不正确。

这些是运行cmake配置命令时变量的值:

代码语言:javascript
运行
复制
-- OPENCV_JAVA_DIR = /opencv
-- ANDROID_EXECUTABLE = FALSE
-- ANDROID_BUILD_BASE_DIR = 
-- OpenCV_BINARY_DIR= /home/flavio/Downloads/opencv/build_manual

我的Cmake构建标志中是否有一些配置错误,或者是完全不同的错误?

谢谢你的帮助!

相关问题

Cmake找不到蚂蚁

Cmake无法识别Java

Ant没有显示安装的情况,尽管它是

到目前为止,我已尝试过所有建议的改变,但都没有成功。重新安装ant没有帮助,也没有创建指向/usr/share/ant/bin/ant in /usr/bin的可执行存储的符号链接。

使用 Command (在下载的opencv-源代码中的build文件夹中):

代码语言:javascript
运行
复制
cmake \
-DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk/21.0.6113669/build/cmake/android.toolchain.cmake \
-DANDROID_TOOLCHAIN=clang++ \
-DANDROID_ABI=arm64-v8a \
-DANDROID_TARGET_SDK_VERSION=26 \
-DANDROID_MIN_SDK_VERSION=24 \
-DBUILD_JAVA=ON -DBUILD_FAT_JAVA_LIB=ON DBUILD_ZLIB=ON \
-D CMAKE_BUILD_TYPE=Release \
-D ANDROID_NATIVE_API_LEVEL=24 \
-DANDROID_COMPILE_SDK_VERSION=26 \
-D ANDROID_STL=c++_shared \
-D WITH_CUDA=OFF \
-D WITH_MATLAB=OFF \
-D BUILD_ANDROID_EXAMPLES=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=ON -D BUILD_SHARED_LIBS=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_JNI=ON \
-DWITH_OPENCL=ON -DWITH_OPENGL=ON \
-DANT_HOME=/usr/share/ant -DJAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 -DANT_EXECUTABLE=/bin/ant \
-DSTRIP=/home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip \
..

modules/java/android_sdk/CMakeList.txt**:** 提取液

代码语言:javascript
运行
复制
project(${the_module}_android)

if(ANDROID_EXECUTABLE)
  set(OPENCV_JAVA_DIR "${OpenCV_BINARY_DIR}/android_sdk" CACHE INTERNAL "")
else()  # gradle
  set(OPENCV_JAVA_DIR "${ANDROID_BUILD_BASE_DIR}/opencv" CACHE INTERNAL "")
endif()
set(OPENCV_ANDROID_LIB_DIR "${OPENCV_JAVA_DIR}" CACHE INTERNAL "")  # for OpenCV samples

message (STATUS "OPENCV_JAVA_DIR = ${OPENCV_JAVA_DIR}")
message (STATUS "ANDROID_BUILD_BASE_DIR = ${ANDROID_BUILD_BASE_DIR}")
message (STATUS "OpenCV_BINARY_DIR= ${OpenCV_BINARY_DIR}")
file(REMOVE_RECURSE "${OPENCV_JAVA_DIR}")
file(MAKE_DIRECTORY "${OPENCV_JAVA_DIR}/bin")
set(java_src_dir "${OPENCV_JAVA_DIR}/src")
file(MAKE_DIRECTORY "${java_src_dir}")

Cmake终端输出

代码语言:javascript
运行
复制
-- Check for working CXX compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected processor: aarch64
CMake Warning at cmake/OpenCVUtils.cmake:752 (message):
  Unexpected option: WITH_OPENGL (=ON)

  Condition: IF (NOT;ANDROID;AND;NOT;WINRT)
Call Stack (most recent call first):
  CMakeLists.txt:308 (OCV_OPTION)


-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.18", minimum required is "2.7") 
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3.2") 
-- Looking for ccache - not found
<---------- Performed Tests have been cut out from this output to meet character-limit of stackoverflow questions ----------->
-- ANDROID: TRUE
-- Update variable ANDROID_SDK_ROOT from environment: /home/flavio/Android/Sdk
-- Update variable ANDROID_HOME from environment: /home/flavio/Android/Sdk
Android: Projects builds are DISABLED
-- Looking for dlerror in dl
-- Looking for dlerror in dl - found
-- ADE: Download: v0.1.1f.zip
-- Allocator metrics storage type: 'int'
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse3.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.ssse3.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse4_1.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse4_2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx512_skx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx512_skx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin512.avx512_skx.cpp
-- Excluding from source files list: modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/flavio/Downloads/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
-- Excluding from source files list: modules/features2d/src/fast.avx2.cpp
-- OPENCV_JAVA_DIR = /opencv
-- ANDROID_BUILD_BASE_DIR = 
-- OpenCV_BINARY_DIR= /home/flavio/Downloads/opencv/build_manual
CMake Error at modules/java/android_sdk/CMakeLists.txt:15 (file):
  file problem creating directory: /opencv/bin


CMake Error at modules/java/android_sdk/CMakeLists.txt:17 (file):
  file problem creating directory: /opencv/src


CMake Error: Could not open file for write in copy operation /opencv/AndroidManifest.xml.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:121 (configure_file):
  configure_file Problem configuring file


CMake Error: Could not open file for write in copy operation /opencv/build.gradle.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:121 (configure_file):
  configure_file Problem configuring file


CMake Error: Could not open file for write in copy operation /opencv/res/values/attrs.xml.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:121 (configure_file):
  configure_file Problem configuring file


CMake Error: Could not open file for write in copy operation /opencv/libcxx_helper/CMakeLists.txt.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:133 (configure_file):
  configure_file Problem configuring file


CMake Error: Could not open file for write in copy operation /opencv/libcxx_helper/dummy.cpp.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:133 (configure_file):
  configure_file Problem configuring file


CMake Error: Could not open file for write in copy operation /opencv/build.gradle.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:160 (configure_file):
  configure_file Problem configuring file


-- Android OpenCV Manager is ignored
-- 
-- General configuration for OpenCV 4.5.1 =====================================
--   Version control:               unknown
-- 
--   Platform:
--     Timestamp:                   2022-03-20T09:57:50Z
--     Host:                        Linux 5.13.0-35-generic x86_64
--     Target:                      Android 1 aarch64
--     CMake:                       3.16.3
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   CPU/HW features:
--     Baseline:                    NEON FP16
-- 
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ standard:                11
--     C++ Compiler:                /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  (ver 9.0)
--     C++ flags (Release):         -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments    -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG   -DNDEBUG
--     C++ flags (Debug):           -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments    -fvisibility=hidden -fvisibility-inlines-hidden -O0   -DDEBUG -D_DEBUG
--     C Compiler:                  /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
--     C flags (Release):           -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments    -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG   -DNDEBUG
--     C flags (Debug):             -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments    -fvisibility=hidden -fvisibility-inlines-hidden -O0   -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments   -Wl,--as-needed  
--     Linker flags (Debug):        -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments   -Wl,--as-needed  
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          ade dl m log
--     3rdparty dependencies:       libcpufeatures ittnotify libprotobuf zlib libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf quirc tegra_hal
-- 
--   OpenCV modules:
--     To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java ml objdetect photo stitching ts video videoio
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 python2 python3
--     Applications:                tests
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   Android NDK:                   /home/flavio/Android/Sdk/ndk/21.0.6113669 (ver 21.0.6113669)
--     Android ABI:                 arm64-v8a
--     NDK toolchain:               aarch64-linux-android-4.9
--     STL type:                    c++_shared
--     Native API level:            24
--   Android SDK:                   not used, projects are not built
-- 
--   GUI: 
--     OpenGL support:              NO
-- 
--   Media I/O: 
--     ZLib:                        build (ver 1.2.11)
--     JPEG:                        build-libjpeg-turbo (ver 2.0.6-62)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         build (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.0.10)
--     JPEG 2000:                   build (ver 2.3.1)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--     Protobuf:                    build (3.5.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/flavio/Downloads/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:                          export all functions
--     ant:                         /bin/ant (ver )
--     Java wrappers:               YES
--     Java tests:                  NO
-- 
--   Install to:                    /home/flavio/Downloads/opencv/build_manual/install
-- -----------------------------------------------------------------
-- 
-- Configuring incomplete, errors occurred!
See also "/home/flavio/Downloads/opencv/build_manual/CMakeFiles/CMakeOutput.log".
See also "/home/flavio/Downloads/opencv/build_manual/CMakeFiles/CMakeError.log".
EN

回答 1

Stack Overflow用户

发布于 2022-07-28 11:39:34

我也有类似的错误,所以我通过打开-DBUILD_ANDROID_PROJECTS=ON修复了所有不兼容的"SDK工具版本“或"gradle版本”。然后,gradle可以在ANDROID_BUILD_BASE_DIR中设置所有必要的路径,比如modules/java/android_sdk/CMakeLists.txt:15

例如,要更新SDK工具:>设置>系统设置> android > SDK工具>更新Android构建工具和NDK(并排)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71546091

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档