Error to cross compile into arm64-v8a by CV 4.3.0

asked 2020-06-02 22:45:06 -0600

HomanH gravatar image

updated 2020-06-03 17:51:53 -0600

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. Part 8, section 6-1 for detail.

edit retag flag offensive close merge delete