Skip to content

fix core module android arm64 build#19521

Merged
alalek merged 2 commits intoopencv:3.4from
zchrissirhcz:3.4-fix-core-module-android-arm64-build
Feb 14, 2021
Merged

fix core module android arm64 build#19521
alalek merged 2 commits intoopencv:3.4from
zchrissirhcz:3.4-fix-core-module-android-arm64-build

Conversation

@zchrissirhcz
Copy link
Copy Markdown
Contributor

This PR fix 3.4 branch's core module failure build on android arm64, by determine and including arm_neon.h header file.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake


#if defined __ARM_NEON && defined __aarch64__
#include <arm_neon.h>
#endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be handled by this code.

Could you please add dump of error message and passed compiler options?

@alalek
Copy link
Copy Markdown
Member

alalek commented Feb 13, 2021

Can't reproduce problem with:

... android env: NDK 21 ...
cmake -GNinja <opencv> -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DANDROID_ABI="arm64-v8a"
ninja install

Please provide more details to reproduce observed problem.

  • CMake stdout (from clean build)
  • files from build folder: CMakeCache.txt and CMakeVars.txt (as attachment)
  • failed compiler command line

@zchrissirhcz
Copy link
Copy Markdown
Contributor Author

zchrissirhcz commented Feb 14, 2021

Build Command

Details

I created opencv/build/android-arm64-build-r18.cmd (on Windows) with contents:

@echo off

set ANDROID_NDK=D:/soft/Android/ndk-r18b
set TOOLCHAIN=%ANDROID_NDK%/build/cmake/android.toolchain.cmake

set BUILD_DIR=android-arm64-r18b
if not exist %BUILD_DIR% md %BUILD_DIR%
cd %BUILD_DIR%

cmake -G Ninja ^
    -DCMAKE_TOOLCHAIN_FILE=%TOOLCHAIN% ^
    -DANDROID_LD=lld ^
    -DANDROID_ABI="arm64-v8a" ^
    -DANDROID_PLATFORM=android-24 ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DCMAKE_INSTALL_PREFIX=d:/lib/opencv/4.5.1-pr-android ^
    -DBUILD_LIST=core,imgcodecs ^
    -D BUILD_TESTS=OFF ^
    -D BUILD_PERF_TESTS=OFF ^
    -D WITH_CUDA=OFF ^
    -D WITH_VTK=OFF ^
    -D WITH_MATLAB=OFF ^
    -D BUILD_DOCS=OFF ^
    -D BUILD_opencv_python3=OFF ^
    -D BUILD_opencv_python2=OFF ^
    -D WITH_IPP=OFF ^
    -DBUILD_ANDROID_PROJECTS=OFF ^
    -DBUILD_ANDROID_EXAMPLES=OFF ^
    -DBUILD_ANDROID_SERVICE=OFF ^
    -D WITH_CUDA=OFF ^
    -D WITH_OPENCL=OFF ^
    -D WITH_VTK=OFF ^
    -D WITH_MATLAB=OFF ^
    -D BUILD_DOCS=OFF ^
    -D BUILD_opencv_python3=OFF ^
    -D BUILD_opencv_python2=OFF ^
    -D WITH_IPP=OFF ^
    -D WITH_WEBP=OFF ^
    -D WITH_JASPER=OFF ^
    -D WITH_OPENEXR=OFF ^
    -D WITH_OPENGL=OFF ^
    -D WITH_OPENNI=OFF ^
    -D WITH_OPENNI2=OFF ^
    -D WITH_GDCM=OFF ^
    -D WITH_PVAPI=OFF ^
    -D WITH_ARAVIS=OFF ^
    -D WITH_QT=OFF ^
    -D WITH_WIN32UI=OFF ^
    -D WITH_TBB=OFF ^
    -D WITH_HPX=OFF ^
    -D WITH_TIFF=OFF ^
    -D BUILD_JAVA=OFF ^
    -D BUILD_FAT_JAVA_LIB=OFF ^
    -D CV_DISABLE_OPTIMIZATION=ON ^
    -D BUILD_TIFF=OFF ^
    -D BUILD_OPENJPEG=OFF ^
    -D BUILD_JASPER=OFF ^
    -D BUILD_JPEG=OFF ^
    -D BUILD_OPENEXR=OFF ^
    -D BUILD_WEBP=OFF ^
    -D BUILD_TBB=OFF ^
    -D BUILD_IPP_IW=OFF ^
    -D BUILD_ITT=OFF ^
    -DWITH_OPENJPEG=OFF ^
    -DWITH_DSHOW=OFF ^
    -DWITH_MSMF=OFF ^
    -DWITH_MSMF_DXVA=OFF ^
    -DCV_TRACE=OFF ^
    -DWITH_IMGCODEC_HDR=OFF ^
    -DWITH_IMGCODEC_SUNRASTER=OFF ^
    -DWITH_IMGCODEC_PXM=OFF ^
    -DWITH_IMGCODEC_PFM=OFF ^
    -DWITH_JPEG=OFF ^
    -DBUILD_opencv_apps=OFF ^
    -DCPU_BASELINE_DISABLE=ON ^
    -DCPU_BASELINE_DETECT=OFF ^
    -DENABLE_PRECOMPILED_HEADERS=OFF ^
    -DWITH_FFMPEG=OFF ^
    -DWITH_PROTOBUF=OFF ^
    -DBUILD_PERF_TESTS=OFF ^
    -DBUILD_TESTS=OFF ^
    -DWITH_QUIRC=OFF ^
    -DOPENCV_CMAKE_DEBUG_MESSAGES=OFF ^
    -DWITH_DIRECTX=OFF ^
    ../..
cd ..

CMake Output

-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/soft/Android/ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/soft/Android/ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected processor: aarch64
-- Performing Test HAVE_CXX11 (check file: cmake/checks/cxx11.cpp)
-- Performing Test HAVE_CXX11 - Success
-- Found PythonInterp: D:/soft/Miniconda3/python.exe (found suitable version "3.7.7", minimum required is "2.7")
CMake Warning at cmake/OpenCVDetectPython.cmake:81 (message):
  CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:

  PYTHON_EXECUTABLE=D:/soft/Miniconda3/python.exe

  PYTHON_VERSION_STRING=3.7.7

  Consider providing the 'PYTHON2_EXECUTABLE' variable via CMake command line
  or environment variables

Call Stack (most recent call first):
  cmake/OpenCVDetectPython.cmake:271 (find_python)
  CMakeLists.txt:611 (include)


-- Could NOT find Python2 (missing: Python2_EXECUTABLE Interpreter)
    Reason given by package:
        Interpreter: Wrong major version for the interpreter "D:/soft/Miniconda3/python.exe"

-- Found PythonInterp: D:/soft/Miniconda3/python.exe (found suitable version "3.7.7", minimum required is "3.2")
-- Looking for ccache - not found
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Success
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Success
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Success
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Success
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Success
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_C_WERROR_RETURN_TYPE
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_CXX_WERROR_ADDRESS
-- Performing Test HAVE_CXX_WERROR_ADDRESS - Success
-- Performing Test HAVE_C_WERROR_ADDRESS
-- Performing Test HAVE_C_WERROR_ADDRESS - Success
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Success
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Success
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Success
-- Performing Test HAVE_C_WUNDEF
-- Performing Test HAVE_C_WUNDEF - Success
-- Performing Test HAVE_CXX_WINIT_SELF
-- Performing Test HAVE_CXX_WINIT_SELF - Success
-- Performing Test HAVE_C_WINIT_SELF
-- Performing Test HAVE_C_WINIT_SELF - Success
-- Performing Test HAVE_CXX_WPOINTER_ARITH
-- Performing Test HAVE_CXX_WPOINTER_ARITH - Success
-- Performing Test HAVE_C_WPOINTER_ARITH
-- Performing Test HAVE_C_WPOINTER_ARITH - Success
-- Performing Test HAVE_CXX_WSHADOW
-- Performing Test HAVE_CXX_WSHADOW - Success
-- Performing Test HAVE_C_WSHADOW
-- Performing Test HAVE_C_WSHADOW - Success
-- Performing Test HAVE_CXX_WSIGN_PROMO
-- Performing Test HAVE_CXX_WSIGN_PROMO - Success
-- Performing Test HAVE_C_WSIGN_PROMO
-- Performing Test HAVE_C_WSIGN_PROMO - Success
-- Performing Test HAVE_CXX_WUNINITIALIZED
-- Performing Test HAVE_CXX_WUNINITIALIZED - Success
-- Performing Test HAVE_C_WUNINITIALIZED
-- Performing Test HAVE_C_WUNINITIALIZED - Success
-- Performing Test HAVE_CXX_WINCONSISTENT_MISSING_OVERRIDE
-- Performing Test HAVE_CXX_WINCONSISTENT_MISSING_OVERRIDE - Success
-- Performing Test HAVE_C_WINCONSISTENT_MISSING_OVERRIDE
-- Performing Test HAVE_C_WINCONSISTENT_MISSING_OVERRIDE - Success
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Success
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Success
-- Performing Test HAVE_CXX_WNO_COMMENT
-- Performing Test HAVE_CXX_WNO_COMMENT - Success
-- Performing Test HAVE_C_WNO_COMMENT
-- Performing Test HAVE_C_WNO_COMMENT - Success
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_CXX_QUNUSED_ARGUMENTS
-- Performing Test HAVE_CXX_QUNUSED_ARGUMENTS - Success
-- Performing Test HAVE_C_QUNUSED_ARGUMENTS
-- Performing Test HAVE_C_QUNUSED_ARGUMENTS - Success
-- Performing Test HAVE_CPU_NEON_SUPPORT (check file: cmake/checks/cpu_neon.cpp)
-- Performing Test HAVE_CPU_NEON_SUPPORT - Success
-- Performing Test HAVE_CPU_FP16_SUPPORT (check file: cmake/checks/cpu_fp16.cpp)
-- Performing Test HAVE_CPU_FP16_SUPPORT - Success
-- Performing Test HAVE_CPU_BASELINE_FLAGS
-- Performing Test HAVE_CPU_BASELINE_FLAGS - Success
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN - Success
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN - Success
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN - Success
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN - Success
-- Performing Test HAVE_LINK_AS_NEEDED
-- Performing Test HAVE_LINK_AS_NEEDED - Success
-- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for posix_memalign
-- Looking for posix_memalign - found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for memalign
-- Looking for memalign - found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Searching 16 bit integer - Using unsigned short
-- Check if the system is big endian - little endian
-- Found ZLIB: D:/soft/Android/ndk-r18b/platforms/android-24/arch-arm64/usr/lib/libz.so (found suitable version "1.2.7", minimum required is "1.2.3")
-- The ASM compiler identification is Clang
-- Found assembler: D:/soft/Android/ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Performing Test HAVE_C_WNO_UNDEF
-- Performing Test HAVE_C_WNO_UNDEF - Success
-- Performing Test HAVE_C_WNO_CAST_ALIGN
-- Performing Test HAVE_C_WNO_CAST_ALIGN - Success
-- Performing Test HAVE_C_WNO_IMPLICIT_FALLTHROUGH
-- Performing Test HAVE_C_WNO_IMPLICIT_FALLTHROUGH - Success
-- Performing Test HAVE_C_WNO_UNUSED_PARAMETER
-- Performing Test HAVE_C_WNO_UNUSED_PARAMETER - Success
-- Performing Test HAVE_C_WNO_SIGN_COMPARE
-- Performing Test HAVE_C_WNO_SIGN_COMPARE - Success
CMake Deprecation Warning at 3rdparty/carotene/hal/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at 3rdparty/carotene/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Using whitelist: opencv_core;opencv_imgcodecs
-- Module opencv_calib3d disabled by whitelist
-- Module opencv_features2d disabled by whitelist
-- Module opencv_flann disabled by whitelist
-- Module opencv_highgui disabled by whitelist
-- Module opencv_java_bindings_generator disabled by whitelist
-- Module opencv_js_bindings_generator disabled by whitelist
-- Module opencv_ml disabled by whitelist
-- Module opencv_objdetect disabled by whitelist
-- Module opencv_photo disabled by whitelist
-- Module opencv_shape disabled by whitelist
-- Module opencv_stitching disabled by whitelist
-- Module opencv_superres disabled by whitelist
-- Module opencv_video disabled by whitelist
-- Module opencv_videoio disabled by whitelist
-- Module opencv_videostab disabled by whitelist
-- Allocator metrics storage type: 'int'
-- Excluding from source files list (optimization is disabled): modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list (optimization is disabled): modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list (optimization is disabled): modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list (optimization is disabled): modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list (optimization is disabled): modules/imgproc/src/resize.sse4_1.cpp
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS - Success
--
-- General configuration for OpenCV 3.4.13-dev =====================================
--   Version control:               3.4.13-98-gfba70f7991
--
--   Platform:
--     Timestamp:                   2021-02-14T02:16:48Z
--     Host:                        Windows 10.0.18363 AMD64
--     Target:                      Android 1 aarch64
--     CMake:                       3.19.4
--     CMake generator:             Ninja
--     CMake build tool:            D:/soft/ninja/ninja.exe
--     Configuration:               Release
--
--   CPU/HW features:
--     Baseline:                    NEON FP16
--       required:                  NEON
--       disabled:                  ON VFPV3
--
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++11:                       YES
--     C++ Compiler:                D:/soft/Android/ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe  (ver 7.0)
--     C++ flags (Release):         -isystem D:/soft/Android/ndk-r18b/sysroot/usr/include/aarch64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11    -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):           -isystem D:/soft/Android/ndk-r18b/sysroot/usr/include/aarch64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11    -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 -fno-limit-debug-info   -DDEBUG -D_DEBUG
--     C Compiler:                  D:/soft/Android/ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
--     C flags (Release):           -isystem D:/soft/Android/ndk-r18b/sysroot/usr/include/aarch64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -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):             -isystem D:/soft/Android/ndk-r18b/sysroot/usr/include/aarch64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -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 -fno-limit-debug-info   -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot D:/soft/Android/ndk-r18b/platforms/android-24/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LD:/soft/Android/ndk-r18b/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now   -Wl,--as-needed
--     Linker flags (Debug):        -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot D:/soft/Android/ndk-r18b/platforms/android-24/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LD:/soft/Android/ndk-r18b/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now   -Wl,--as-needed
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          z dl m log
--     3rdparty dependencies:       libcpufeatures libpng tegra_hal
--
--   OpenCV modules:
--     To be built:                 core imgcodecs imgproc
--     Disabled:                    world
--     Disabled by dependency:      calib3d features2d flann highgui java_bindings_generator js_bindings_generator ml objdetect photo shape stitching superres video videoio videostab
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev dnn java python2 python3 ts viz
--     Applications:                -
--     Documentation:               NO
--     Non-free algorithms:         NO
--
--   Android NDK:                   D:/soft/Android/ndk-r18b (ver 18.1.5063045)
--     Android ABI:                 arm64-v8a
--     NDK toolchain:               aarch64-linux-android-clang
--     STL type:                    c++_static
--     Native API level:            24
--   Android SDK:                   not used, projects are not built
--
--   GUI:
--
--   Media I/O:
--     ZLib:                        z (ver 1.2.7)
--     PNG:                         build (ver 1.6.37)
--     HDR:                         NO
--     SUNRASTER:                   NO
--     PXM:                         NO
--
--   Video I/O:
--
--   Parallel framework:            pthreads
--
--   Other third-party libraries:
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--
--   Python (for build):            D:/soft/Miniconda3/python.exe
--
--   Install to:                    D:/lib/opencv/4.5.1-pr-android
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: D:/work/opencv-latest/build/android-arm64-r18b

Ninja Output

[1/243] Building C object 3rdparty/cpufeatures/CMakeFiles/libcpufeatures.dir/cpu-features.c.o
../../3rdparty/cpufeatures/cpu-features.c:147:44: warning: implicitly declaring library function 'strerror' with type 'char *(int)' [-Wimplicit-function-declaration]
        D("Can't open %s: %s\n", pathname, strerror(errno));
                                           ^
../../3rdparty/cpufeatures/cpu-features.c:147:44: note: include the header <string.h> or explicitly provide a declaration for 'strerror'
../../3rdparty/cpufeatures/cpu-features.c:398:13: warning: implicitly declaring library function 'memchr' with type 'void *(const void *, int, unsigned long)' [-Wimplicit-function-declaration]
        q = memchr(p, ',', end-p);
            ^
../../3rdparty/cpufeatures/cpu-features.c:398:13: note: include the header <string.h> or explicitly provide a declaration for 'memchr'
2 warnings generated.
[49/243] Building CXX object 3rdparty/carotene/hal/carotene/CMakeFiles/carotene_objs.dir/src/div.cpp.o
../../3rdparty/carotene/src/div.cpp:93:19: warning: unused function 'divSaturate' [-Wunused-function]
inline uint32x2_t divSaturate<uint32x2_t>(const uint32x2_t &v1, const uint32x2_t &v2, const float scale)
                  ^
../../3rdparty/carotene/src/div.cpp:122:19: warning: unused function 'divWrap' [-Wunused-function]
inline uint32x2_t divWrap<uint32x2_t>(const uint32x2_t &v1, const uint32x2_t &v2, const float scale)
                  ^
../../3rdparty/carotene/src/div.cpp:127:20: warning: unused function 'vtstq' [-Wunused-function]
inline  uint32x4_t vtstq(const uint32x4_t  & v0, const uint32x4_t  & v1) { return vtstq_u32(v0, v1); }
                   ^
../../3rdparty/carotene/src/div.cpp:134:20: warning: unused function 'vtst' [-Wunused-function]
inline  uint32x2_t vtst(const uint32x2_t  & v0, const uint32x2_t  & v1) { return vtst_u32(v0, v1); }
                   ^
../../3rdparty/carotene/src/div.cpp:270:19: warning: unused function 'recipSaturate' [-Wunused-function]
inline uint32x2_t recipSaturate<uint32x2_t>(const uint32x2_t &v2, const float scale)
                  ^
../../3rdparty/carotene/src/div.cpp:297:19: warning: unused function 'recipWrap' [-Wunused-function]
inline uint32x2_t recipWrap<uint32x2_t>(const uint32x2_t &v2, const float scale)
                  ^
6 warnings generated.
[68/243] Building CXX object 3rdparty/carotene/hal/carotene/CMakeFiles/carotene_objs.dir/src/mul.cpp.o
../../3rdparty/carotene/src/mul.cpp:932:18: warning: unused function 'mulSaturate' [-Wunused-function]
inline int32x2_t mulSaturate<int32x2_t>(const int32x2_t &v1, const int32x2_t &v2, const float scale)
                 ^
../../3rdparty/carotene/src/mul.cpp:935:19: warning: unused function 'mulSaturate' [-Wunused-function]
inline uint32x2_t mulSaturate<uint32x2_t>(const uint32x2_t &v1, const uint32x2_t &v2, const float scale)
                  ^
../../3rdparty/carotene/src/mul.cpp:961:18: warning: unused function 'mulWrap' [-Wunused-function]
inline int32x2_t mulWrap<int32x2_t>(const int32x2_t &v1, const int32x2_t &v2, const float scale)
                 ^
../../3rdparty/carotene/src/mul.cpp:964:19: warning: unused function 'mulWrap' [-Wunused-function]
inline uint32x2_t mulWrap<uint32x2_t>(const uint32x2_t &v1, const uint32x2_t &v2, const float scale)
                  ^
4 warnings generated.
[141/243] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/rand.cpp.o
FAILED: modules/core/CMakeFiles/opencv_core.dir/src/rand.cpp.o
D:\soft\Android\ndk-r18b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android24 --gcc-toolchain=D:/soft/Android/ndk-r18b/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64 --sysroot=D:/soft/Android/ndk-r18b/sysroot -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I. -I../../modules/core/include -Imodules/core -I../../3rdparty/cpufeatures -isystem D:/soft/Android/ndk-r18b/sources/cxx-stl/llvm-libc++/include -isystem D:/soft/Android/ndk-r18b/sources/cxx-stl/llvm-libc++abi/include -isystem D:/soft/Android/ndk-r18b/sysroot/usr/include/aarch64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11    -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 -fPIC -MD -MT modules/core/CMakeFiles/opencv_core.dir/src/rand.cpp.o -MF modules\core\CMakeFiles\opencv_core.dir\src\rand.cpp.o.d -o modules/core/CMakeFiles/opencv_core.dir/src/rand.cpp.o -c ../../modules/core/src/rand.cpp
../../modules/core/src/rand.cpp:250:9: error: unknown type name 'float32x4x2_t'
        float32x4x2_t q = vld2q_f32((const float*)(p + i));
        ^
../../modules/core/src/rand.cpp:250:27: error: use of undeclared identifier 'vld2q_f32'
        float32x4x2_t q = vld2q_f32((const float*)(p + i));
                          ^
../../modules/core/src/rand.cpp:252:9: error: unknown type name 'float32x4_t'
        float32x4_t p0 = q.val[0];
        ^
../../modules/core/src/rand.cpp:253:9: error: unknown type name 'float32x4_t'
        float32x4_t p1 = q.val[1];
        ^
../../modules/core/src/rand.cpp:255:18: error: unknown type name 'float32x4_t'
        volatile float32x4_t v0 = vmulq_f32(vld1q_f32(f), p0);
                 ^
../../modules/core/src/rand.cpp:255:45: error: use of undeclared identifier 'vld1q_f32'
        volatile float32x4_t v0 = vmulq_f32(vld1q_f32(f), p0);
                                            ^
../../modules/core/src/rand.cpp:282:9: error: unknown type name 'float32x2_t'
        float32x2_t t = vadd_f32(vmul_f32(
        ^
../../modules/core/src/rand.cpp:283:17: error: use of undeclared identifier 'vdup_n_f32'
                vdup_n_f32((float)(int)temp), vdup_n_f32(p[i][0])),
                ^
../../modules/core/src/rand.cpp:283:47: error: use of undeclared identifier 'vdup_n_f32'
                vdup_n_f32((float)(int)temp), vdup_n_f32(p[i][0])),
                                              ^
../../modules/core/src/rand.cpp:284:17: error: use of undeclared identifier 'vdup_n_f32'
                vdup_n_f32(p[i][1]));
                ^
10 errors generated.
[148/243] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/split.dispatch.cpp.o
ninja: build stopped: subcommand failed.

CMakeCache.txt and CMakeVars.txt

https://drive.google.com/drive/folders/1Db8iqVlGItwhS4nhmbCaFJxC0Rno6Uuu?usp=sharing

@zchrissirhcz
Copy link
Copy Markdown
Contributor Author

Oh I should do more test locally. Sorry for that. Now I know:

Using -DCV_DISABLE_OPTIMIZATION=ON causes neon intrinsics compile error.
Using -DCV_DISABLE_OPTIMIZATION=OFF will build OK.

@zchrissirhcz
Copy link
Copy Markdown
Contributor Author

zchrissirhcz commented Feb 14, 2021

The mentioned "missing arm_neon.h" issue, only occur in 3.4 branch, not occured in 4.5.1 branch.

I think -DCV_DISABLE_OPTIMIZATION=ON mean turn off neon optimization on android, thus including arm_neon.h is not as expected, the following modification may be more suitable:

i.e. change:

#elif defined __ARM_NEON && defined __aarch64__

to

#elif CV_NEON && defined __aarch64__

When building for Android ARM platform, cmake with
`-D CV_DISABLE_OPTIMIZATION=ON`, the expected behavior is
not using ARM NEON, using naive computation instead.

This commit fix the un-expected compile error for neon intrinsincs.
@alalek alalek merged commit 743099f into opencv:3.4 Feb 14, 2021
@zchrissirhcz zchrissirhcz deleted the 3.4-fix-core-module-android-arm64-build branch February 14, 2021 19:42
@alalek alalek mentioned this pull request Feb 21, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug category: build/install category: core platform: arm ARM boards related issues: RPi, NVIDIA TK/TX, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants