Can not build single dynamic library (libopencv_java4.so) for Android

asked 2020-11-13 16:08:18 -0600

Kafan gravatar image

I am on Mac and trying to build the dynamic library for some of the modules and finally create a single .so file for Android. I have downloaded and built from source (Opencv release 4.5.0). The static libraries of individual modules gets created after running the

build_sdk.py --no_samples_build.

Although without the --no_samples_build the build process throws error but that in not the problem I am trying to solve.

Coming back to the issue, as per few old tutorials, when I try to create a single stripped .so file. using the following command

$NDK/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang++ -shared -o libopencv_tiny.so --sysroot=$NDK/21.3.6528147/platforms/android-21/arch-arm64 -Wl,--whole-archive libopencv_core.a libopencv_imgcodecs.a libopencv_video.a libopencv_imgproc.a -Wl,--whole-archive

It throws plenty of errors.

/android_sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lc++ /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(mulodi4.o): In function __mulodi4': external/compiler-rt/lib/builtins/mulodi4.c:23: multiple definition of__mulodi4' /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(mulodi4.o):external/compiler-rt/lib/builtins/mulodi4.c:23: first defined here /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o): In function toRep': external/compiler-rt/lib/builtins/fp_lib.h:232: multiple definition of__cmpdf2' /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o):external/compiler-rt/lib/builtins/fp_lib.h:232: first defined here /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o): In function toRep': external/compiler-rt/lib/builtins/fp_lib.h:232: multiple definition of__eqdf2' /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o):external/compiler-rt/lib/builtins/fp_lib.h:232: first defined here /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o): In function toRep': external/compiler-rt/lib/builtins/fp_lib.h:232: multiple definition of__gedf2' /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o):external/compiler-rt/lib/builtins/fp_lib.h:232: first defined here /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o): In function toRep': external/compiler-rt/lib/builtins/fp_lib.h:232: multiple definition of__gtdf2' /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o):external/compiler-rt/lib/builtins/fp_lib.h:232: first defined here /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o): In function toRep': external/compiler-rt/lib/builtins/fp_lib.h:232: multiple definition of__ledf2' /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o):external/compiler-rt/lib/builtins/fp_lib.h:232: first defined here /android_sdk/ndk/21.3.6528147/platforms/android-21/arch-arm64/usr/lib/libcompiler_rt-extras.a(comparedf2.o): In function toRep': external/compiler-rt/lib/builtins/fp_lib.h:232: multiple definition of__ltdf2' /android_sdk/ndk/21.3 ... (more)

edit retag flag offensive close merge delete