I use CMake-GUI with Newest NDK 21.2.6472646 on Windows 10. If I remove BUILD_opencv_java, CMake will finish.
[ 98%] Built target gen_opencv_java_source
[ 98%] Linking CXX shared module ..\..\..\jni\arm64-v8a\libopencv_java4.so
..\..\..\lib\arm64-v8a\libopencv_core.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)
mingw32-make[2]: *** [modules\java\jni\CMakeFiles\opencv_java.dir\build.make:281: jni/arm64-v8a/libopencv_java4.so] Error 1
After 12 hours, I knew how to fix it.
@echo off
rem Please replace command with your ranlib at %NDK Path%/toolchains/llvm/prebuilt/windows-x86_64/bin/
C:/Users/Homan/AppData/Local/Android/Sdk/ndk/21.2.6472646/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android-ranlib.exe %1 %2 %3 %4
echo "Fixed %1"
Here is my fix.bat. Please replace the exe file with your ranlib.exe.
You can check my [OpenCV note on Medium.com](https://medium.com/@homanhuang/android-opencv-part-8-diy-sdk-contrib-modules-on-windows-7d7e618402fc). Part 8, section 6-1 for detail.
↧