Issue 1:
System information (version)

OpenCV => 4.1.2

Operating System / Platform => Mac

Compiler => clang

Detailed description

Detected processor: armv7-a

sizeof(void) = 4 on 64 bit processor. Assume 32-bit compilation mode

Looking for ccache - not found

FP16 is not supported by C++ compiler

OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT

libjpeg-turbo: VERSION = 2.0.2, BUILD = opencv-4.1.2-libjpeg-turbo

Android SDK Tools: Ant (Eclipse) builds are NOT supported by Android SDK

Android SDK Build Tools: Gradle 3.0.0+ builds support is available

Android SDK Tools: Prepare Android projects for using Gradle 3.0.0+ build scripts

Android Gradle Plugin version: 3.2.1

Caffe: NO

Protobuf: NO

Glog: NO

freetype2: NO

harfbuzz: NO

Module opencv_ovis disabled because OGRE3D was not found

No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.

Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.

Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.

Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h

Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h

Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags

Module opencv_dnn_objdetect disabled because opencv_dnn dependency can't be resolved!

Module opencv_dnn_superres disabled because opencv_dnn dependency can't be resolved!

Module opencv_text disabled because opencv_dnn dependency can't be resolved!

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

Excluding from source files list: modules/imgproc/src/sumpixels.avx512_skx.cpp

Excluding from source files list: modules/features2d/src/fast.avx2.cpp

Android OpenCV Manager is ignored

General configuration for OpenCV 4.1.2 =====================================

Version control: unknown

Extra modules:

Location (extra): /Users/Elvis/Downloads/OpenCV/opencv-contrib/modules

Version control (extra): unknown

Platform:

Timestamp: 2019-11-29T17:39:44Z

Host: Darwin 19.0.0 x86_64

Target: Android 1 armv7-a

CMake: 3.16.0-rc4

CMake generator: Unix Makefiles

CMake build tool: /usr/bin/make

Configuration: Release

CPU/HW features:

Baseline:

requested: DETECT

C/C++:

Built as dynamic libs?: NO

C++ Compiler: /Users/Elvis/Library/Android/sdk/ndk/19.2.5345600/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ (ver 8.0)

C++ flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++ -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 -O2 -DNDEBUG -DNDEBUG

C++ flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++ -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

C Compiler: /Users/Elvis/Library/Android/sdk/ndk/19.2.5345600/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang

C flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -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 -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 -O2 -DNDEBUG -DNDEBUG

C flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -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 -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

Linker flags (Release): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now

Linker flags (Debug): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now

ccache: NO

Precompiled headers: NO

Extra dependencies: /Users/Elvis/Library/Android/sdk/ndk/19.2.5345600/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/arm-linux-androideabi/libz.a dl m log

3rdparty dependencies: libcpufeatures ittnotify libjpeg-turbo libwebp libpng libtiff libjasper IlmImf quirc tegra_hal

OpenCV modules:

To be built: aruco bgsegm bioinspired calib3d ccalib core dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc java line_descriptor ml objdetect optflow phase_unwrapping photo plot quality rgbd saliency shape stereo stitching structured_light superres surface_matching tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto

Disabled: datasets dnn reg world

Disabled by dependency: dnn_objdetect dnn_superres text

Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype gapi hdf js matlab ovis python2 python3 sfm ts viz

Applications: android_service

Documentation: NO

Non-free algorithms: YES

Android NDK: /Users/Elvis/Library/Android/sdk/ndk/19.2.5345600 (ver 19.2.5345600)

Android ABI: arm64-v8a

NDK toolchain: aarch64-linux-android-clang

STL type: c++_static

Native API level: 28

Android SDK: /Users/Elvis/Library/Android/sdk (tools: 26.1.1 build tools: 29.0.2)

GUI:

Media I/O:

ZLib: /Users/Elvis/Library/Android/sdk/ndk/19.2.5345600/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/arm-linux-androideabi/libz.a (ver 1.2.7)

JPEG: build-libjpeg-turbo (ver 2.0.2-62)

WEBP: build (ver encoder: 0x020e)

PNG: build (ver 1.6.37)

TIFF: build (ver 42 - 4.0.10)

JPEG 2000: build (ver 1.900.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)

Python (for build): /usr/bin/python2.7

Java: export all functions

ant: NO

Java wrappers: YES

Java tests: NO

Install to: /Users/Elvis/Downloads/OpenCV/opencv-android/install

Configuring done

Generating done

Steps to reproduce

[ 99%] Built target opencv_java_android_source_copy

[ 99%] Linking CXX shared library ../../../jni/arm64-v8a/libopencv_java4.so

../../../lib/arm64-v8a/libopencv_phase_unwrapping.a: error adding symbols: Archive has no index; run ranlib to add one

clang++: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [jni/arm64-v8a/libopencv_java4.so] Error 1

make[1]: *** [modules/java/jni/CMakeFiles/opencv_java.dir/all] Error 2

make: *** [all] Error 2

Issue 2:
OpenCV => 3.4.4

Operating System / Platform => Android (Windows 10 compile host)

Compiler => MinGW 5.3.0 32bit

Detailed description

I am compiling OpenCV 3.4.4 (world) from source for Android on a Windows 10 host. The compilation of the shared OpenCV libraries seems to finish without error EXCEPT for when hello_android is being linked.

CMake config

-- General configuration for OpenCV 3.4.4 =====================================
-- Version control: 3.4.4
--
-- Platform:
-- Timestamp: 2019-03-01T03:15:46Z
-- Host: Windows 10.0.17763 AMD64
-- Target: Android 1 aarch64
-- CMake: 3.13.0-rc2
-- CMake generator: MinGW Makefiles
-- CMake build tool: C:/Qt/Qt5.11.2/Tools/mingw530_32/bin/mingw32-make.exe
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline: NEON FP16
-- required: NEON
-- disabled: VFPV3
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++11: YES
-- C++ Compiler: C:/android-ndk-r19b-windows-x86_64/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe (ver 8.0)
-- C++ flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++ -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-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -ffunction-sections -fdata-sections -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 -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++ -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-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG
-- C Compiler: C:/android-ndk-r19b-windows-x86_64/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- C flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -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 -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -ffunction-sections -fdata-sections -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 -fno-addrsig -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 -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -ffunction-sections -fdata-sections -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 -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
-- Linker flags (Debug): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: dl m log
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: calib3d core dnn features2d flann highgui imgcodecs imgproc java_bindings_generator ml objdetect photo shape stitching superres video videostab world
-- Disabled: videoio
-- Disabled by dependency: -
-- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java js python2 python3 ts viz
-- Applications: -
-- Documentation: NO
-- Non-free algorithms: NO
--
-- Android NDK: C:/android-ndk-r19b-windows-x86_64 (ver 19.1.5304403)
-- Android ABI: arm64-v8a
-- NDK toolchain: aarch64-linux-android-clang
-- STL type: c++_static
-- Native API level: 23
-- Android SDK: not used, projects are not built
--
-- GUI:
--
-- Media I/O:
-- ZLib: C:/android-ndk-r19b-windows-x86_64/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/libz.a (ver 1.2.7)
-- JPEG: build-libjpeg-turbo (ver 1.5.3-62)
-- WEBP: build (ver encoder: 0x020e)
-- PNG: build (ver 1.6.35)
-- TIFF: build (ver 42 - 4.0.9)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: build (ver 1.7.1)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
--
-- Video I/O:
--
-- Parallel framework: TBB (ver 2018.0 interface 10001)
--
-- Trace: YES (built-in)
--
-- Other third-party libraries:
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.5.1)
--
-- OpenCL: YES (no extra features)
-- Include path: C:/Users/Lenovo/Desktop/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python (for build): NO
--
-- Java:
-- ant: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: C:/Users/Lenovo/Desktop/opencv/build-android-world/install
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Lenovo/Desktop/opencv/build-android-world

As mentioned before, both libopencv_world.so and libtbb.so seems to have been correctly built. They can be found in C:\Users\Lenovo\Desktop\opencv\build-android-world\lib\arm64-v8a. However, linking of hello_android results in undefined references to tbb:: functions.

mingw32-make output

[ 0%] Built target libcpufeatures
[ 6%] Built target libjpeg-turbo
[ 10%] Built target libtiff
[ 23%] Built target libwebp
[ 27%] Built target libjasper
[ 29%] Built target libpng
[ 37%] Built target IlmImf
[ 40%] Built target tbb
[ 49%] Built target libprotobuf
[ 50%] Built target quirc
[ 56%] Built target carotene_objs
[ 57%] Built target tegra_hal
[100%] Built target opencv_world
[100%] Linking CXX executable ..\..\bin\hello-android
C:/android-ndk-r19b-windows-x86_64/toolchains/llvm/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: warning: libtbb.so, needed by ..\..\lib\arm64-v8a\libopencv_world.so, not found (try using -rpath or -rpath-link)
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::task::note_affinity(unsigned short)'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_initialize()'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `typeinfo for tbb::task'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::task_group_context::init()'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_current_slot()'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_max_concurrency(tbb::interface7::task_arena const*)'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::task_group_context::~task_group_context()'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const'
..\..\lib\arm64-v8a\libopencv_world.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
samples\android\CMakeFiles\hello-android.dir\build.make:83: recipe for target 'bin/hello-android' failed
mingw32-make[2]: *** [bin/hello-android] Error 1
CMakeFiles\Makefile2:1994: recipe for target 'samples/android/CMakeFiles/hello-android.dir/all' failed
mingw32-make[1]: *** [samples/android/CMakeFiles/hello-android.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Steps to reproduce

Path to opencv source: C:\Users\Lenovo\Desktop\opencv

Path to build directory: C:\Users\Lenovo\Desktop\opencv\build-android-world

CMake invocation

cmake .. -G "MinGW Makefiles" ^
-DANDROID_ABI=arm64-v8a ^
-DANDROID_NATIVE_API_LEVEL=23 ^
-DANDROID_ARM_NEON=ON ^
-DANDROID_TOOLCHAIN=clang ^
-DCMAKE_TOOLCHAIN_FILE=C:/android-ndk-r19b-windows-x86_64/build/cmake/android.toolchain.cmake ^
-DANDROID_NDK=C:/android-ndk-r19b-windows-x86_64 ^
-DANDROID_SDK=C:/Users/Lenovo/android-sdk ^
-DBUILD_SHARED_LIBS=ON ^
-DCMAKE_BUILD_TYPE=Release ^
-DBUILD_ANDROID_PROJECTS=OFF ^
-DWITH_OPENCL=ON ^
-DWITH_TBB=ON ^
-DENABLE_NEON=ON ^
-DENABLE_CXX11=ON ^
-DBUILD_TESTS=OFF ^
-DBUILD_PERF_TESTS=OFF ^
-DBUILD_opencv_videoio=OFF ^
-DBUILD_opencv_world=ON

mingw32-make [-j4]

This leads eventually to mingw32-make output above