This is how I set up the cmake, in the root of OpenCV 4.9.0. repository:
cmake -DCMAKE_ANDROID_NDK=D:...libAndroidSDKndk25.1.8937393
-DCMAKE_SYSTEM_NAME=Android
-B..OpenCV_4.9.0_buildsandroid_clang_ndk25 -S.
-DANDROID_TOOLCHAIN=clang++
-DANDROID_ABI=arm64-v8a
-D CMAKE_BUILD_TYPE=Release
-D ANDROID_NATIVE_API_LEVEL=24
-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=OFF
-D ANDROID_STL=c++_shared
-D BUILD_SHARED_LIBS=ON
But when I then try to go to android_clang_ndk25
, I can see it still uses mingw header files and mingw linker.
I compile with:
D:...ndk21.1.6352462prebuiltwindows-x86_64binmake.exe install
And get errors:
ld: error: undefined symbol: std::__once_callable
>>> referenced by C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/mutex:710
>>> objects.a(caffe_importer.cpp.obj):(cv::dnn::dnn4_v20231225::(anonymous namespace)::CaffeImporter::extractLayerParams(google::protobuf::Message const&, cv::dnn::dnn4_v20231225::LayerParams&, bool))
>>> referenced by C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/mutex:718
>>> objects.a(caffe_importer.cpp.obj):(cv::dnn::dnn4_v20231225::(anonymous namespace)::CaffeImporter::extractLayerParams(google::protobuf::Message const&, cv::dnn::dnn4_v20231225::LayerParams&, bool))
>>> referenced by C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/mutex:710
>>> objects.a(caffe_importer.cpp.obj):(cv::dnn::dnn4_v20231225::(anonymous namespace)::CaffeImporter::extractLayerParams(google::protobuf::Message const&, cv::dnn::dnn4_v20231225::LayerParams&, bool))
>>> referenced 1093 more times
ld: error: undefined symbol: std::__once_call
>>> referenced by C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/mutex:712
>>> objects.a(caffe_importer.cpp.obj):(cv::dnn::dnn4_v20231225::(anonymous namespace)::CaffeImporter::extractLayerParams(google::protobuf::Message const&, cv::dnn::dnn4_v20231225::LayerParams&, bool))
>>> referenced by C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/mutex:719
>>> objects.a(caffe_importer.cpp.obj):(cv::dnn::dnn4_v20231225::(anonymous namespace)::CaffeImporter::extractLayerParams(google::protobuf::Message const&, cv::dnn::dnn4_v20231225::LayerParams&, bool))
>>> referenced by C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/mutex:712
>>> objects.a(caffe_importer.cpp.obj):(cv::dnn::dnn4_v20231225::(anonymous namespace)::CaffeImporter::extractLayerParams(google::protobuf::Message const&, cv::dnn::dnn4_v20231225::LayerParams&, bool))
>>> referenced 1082 more times
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [modulesdnnCMakeFilesopencv_dnn.dirbuild.make:2858: bin/libopencv_dnn490.dll] Error 1
make[1]: *** [CMakeFilesMakefile2:1870: modules/dnn/CMakeFiles/opencv_dnn.dir/all] Error 2
make: *** [Makefile:165: all] Error 2
Notably, it also says after configuring it is using MinGW:
-- General configuration for OpenCV 4.9.0 =====================================
-- Version control: 4.9.0
--
-- Platform:
-- Timestamp: 2024-04-08T09:17:02Z
-- Host: Windows 10.0.19045 AMD64
-- CMake: 3.25.2
-- CMake generator: MinGW Makefiles
-- CMake build tool: C:/Qt/Tools/mingw1120_64/bin/mingw32-make.exe
-- Configuration: Release