OpenCV Build Source Code for Android

I am learning how to write C ++ code using OpenCV, and I want to run it on Android. I am using Android Studio.

I created a new simple project with C ++ support, and then added my test code to a C ++ file. It seems my own files are compiling and linking.

Now, something else that I don’t think is related to my project causes a lot of errors. Something seems to be inside the NDK. Maybe this is a mistake in the latest version, and if so, what can I do about it?

C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiCopyConstBorder_8u_C4IR_L_as.so): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiConvert_32s16u_C1RSfs_as.so): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiNormRel_L1_32f_C1R_as.so): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiFilterBilateralBorderInit_L_as.so): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiScaleC_32f8u_C1R_as.so): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object 
+4
source share
2 answers

I returned the NDK 14.1.3816874 instead of using the latest NDK 16.1.4479499, and the errors disappeared.

You can find the older NDK here: https://developer.android.com/ndk/downloads/older_releases.html

Hope this helps!

+1
source

Instead of switching to NDK14 from NDK16, you can still do with NDK16 by adding the following to CMakeLists.txt before add_library() :

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a")

Copied from this github discussion

+1
source

Source: https://habr.com/ru/post/1273487/


All Articles