我的编译脚本:
./build_sdk.py --ndk_path ~/opencvspace/android-ndk-r21/ --sdk_path ~/opencvspace/tools/ --extra_modules_path ~/opencvspace/opencv43/opencv_contrib-4.3.0/modules/ --config ~/opencvspace/opencv43/opencv-4.3.0/platforms/android/ndk-18-api-level-21.config.py --no_ccache ~/opencvspace/opencv43/build/ ~/opencvspace/opencv43/opencv-4.3.0/
运行环境如下:
Package configuration:
ABIs = [ ABI("2", "armeabi-v7a", None, 21, cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')), ABI("3", "arm64-v8a", None, 21), ABI("5", "x86_64", None, 21), ABI("4", "x86", None, 21),
]
-- General configuration for OpenCV 4.3.0 =====================================
-- Version control: unknown
-- Extra modules: -- Location (extra): /root/opencvspace/opencv43/opencv_contrib-4.3.0/modules
-- Version control (extra): unknown
-- Platform: -- Timestamp: 2020-04-26T04:11:42Z -- Host: Linux 4.15.0-88-generic x86_64 -- Target: Android 1 armv7-a -- CMake: 3.17.0 -- CMake generator: Ninja -- CMake build tool: /usr/bin/ninja
-- Configuration: RELEASE
-- CPU/HW features: -- Baseline: NEON
-- requested: DETECT
-- C/C++:
-- Built as dynamic libs?: NO
-- C++ standard: 11
-- C++ Compiler: /root/opencvspace/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ (ver 9.0)
-- C++ flags (Release): -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 -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 -Winit-self -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 -Oz -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -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 -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 -Winit-self -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 -fno-limit-debug-info -DDEBUG -D_DEBUG -g
-- C Compiler: /root/opencvspace/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- C flags (Release): -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 -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 -Winit-self -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 -Oz -DNDEBUG -DNDEBUG
-- C flags (Debug): -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 -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 -Winit-self -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 -fno-limit-debug-info -DDEBUG -D_DEBUG -g
-- Linker flags (Release): -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -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,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: ade dl m log
-- 3rdparty dependencies: libcpufeatures ittnotify libprotobuf tbb zlib libjpeg-turbo libwebp libpng libtiff libjasper IlmImf quirc tegra_hal
-- OpenCV modules: -- To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto -- Disabled: world -- Disabled by dependency: - -- Unavailable: alphamat cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java js matlab ovis python2 python3 sfm ts viz -- Applications: - -- Documentation: NO
-- Non-free algorithms: NO
-- Android NDK: /root/opencvspace/android-ndk-r21 (ver 21.0.6113669) -- Android ABI: armeabi-v7a -- NDK toolchain: arm-linux-androideabi-clang -- STL type: c++_shared -- Native API level: 21
-- Android SDK: not used, projects are not built
-- GUI:
-- Media I/O: -- ZLib: build (ver 1.2.11) -- JPEG: build-libjpeg-turbo (ver 2.0.4-62) -- WEBP: build (ver encoder: 0x020f) -- PNG: build (ver 1.6.37) -- TIFF: build (ver 42 - 4.0.10) -- JPEG 2000: build Jasper (ver 1.900.1) -- OpenEXR: build (ver 2.3.0) -- HDR: YES -- SUNRASTER: YES -- PXM: YES
-- PFM: YES
-- Video I/O:
-- Parallel framework: TBB (ver 2020.1 interface 11101)
-- Trace: YES (with Intel ITT)
-- Other third-party libraries: -- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.5.1)
-- Python (for build): /usr/bin/python2.7
-- Java: export all functions -- ant: NO -- Java wrappers: NO
-- Java tests: NO
-- Install to: /root/opencvspace/opencv43/build/o4a/install
最后的错误如下:
-- Configuring incomplete, errors occurred! See also "/root/opencvspace/opencv43/build/o4a/CMakeFiles/CMakeOutput.log". See also "/root/opencvspace/opencv43/build/o4a/CMakeFiles/CMakeError.log". Traceback (most recent call last): File "./build_sdk.py", line 407, in <module> builder.build_library(abi, do_install) File "./build_sdk.py", line 250, in build_library execute(cmd) File "./build_sdk.py", line 30, in execute raise Fail("Child returned: %s" % retcode) __main__.Fail: Child returned: 1
下面是CMakeError.log
Compilation failed: source file: '/root/opencvspace/opencv43/opencv-4.3.0/cmake/checks/cpu_fp16.cpp' check option: '' ===== BUILD LOG ===== Change Dir: /root/opencvspace/opencv43/build/o4a/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_aad58 && [1/2] Building CXX object CMakeFiles/cmTC_aad58.dir/cpu_fp16.cpp.o FAILED: /root/opencvspace/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi21 --gcc-toolchain=/root/opencvspace/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/root/opencvspace/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/sysroot -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 -Oz -DNDEBUG -fPIE -std=c++11 -o CMakeFiles/cmTC_aad58.dir/cpu_fp16.cpp.o -c /root/opencvspace/opencv43/opencv-4.3.0/cmake/checks/cpu_fp16.cpp /root/opencvspace/opencv43/opencv-4.3.0/cmake/checks/cpu_fp16.cpp:21:25: error: use of undeclared identifier 'vcvt_f16_f32' float16x4_t v_dst = vcvt_f16_f32(v_src); ^ 1 error generated. ninja: build stopped: subcommand failed.
===== END =====
Compilation failed: source file: '/root/opencvspace/opencv43/opencv-4.3.0/cmake/checks/cpu_fp16.cpp' check option: ' -mfpu=neon-fp16 -mfp16-format=ieee' ===== BUILD LOG ===== Change Dir: /root/opencvspace/opencv43/build/o4a/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_3b7fa && [1/2] Building CXX object CMakeFiles/cmTC_3b7fa.dir/cpu_fp16.cpp.o FAILED: /root/opencvspace/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi21 --gcc-toolchain=/root/opencvspace/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/root/opencvspace/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/sysroot -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 -Oz -DNDEBUG -fPIE -mfpu=neon-fp16 -mfp16-format=ieee -std=c++11 -o CMakeFiles/cmTC_3b7fa.dir/cpu_fp16.cpp.o -c /root/opencvspace/opencv43/opencv-4.3.0/cmake/checks/cpu_fp16.cpp clang++: error: unknown argument: '-mfp16-format=ieee' ninja: build stopped: subcommand failed.
===== END =====