opencv: OpenCV doesn't link on Android x86/x86_64 with ndk 16.0.4442984 with R_386_GOTOFF error.
System information (version)
- OpenCV => 3.3.0
- Operating System / Platform => Android x86/x86_64
- Compiler => Android toolchain (OpenCV binaries downloaded from github 3.3.0/3.3.1 release, My binary built from Android Studio, ndk-bundle-16.0.4442984 darwin-x86_64-gcc-i686-linux-android-4.9.x)
Detailed description
Can no longer link application for x86 or x86_64, get relocation R_386_GOTOFF against preemptible symbol
in symbols from libippiw.a
and libippicw.a
. Rebuilding OpenCV for Android without IPP support fixes the problem. IPP are only used on x86/x86_64 so this is not a problem for arm builds, but the x86 builds are useful for debugging on HAX accelerated emulator.
Problem appeared after Android ndk upgrade (don’t know my old version). The IPP binaries seems to be a binary only release compiled by Intel so I can’t test rebuilding those libraries, otherwise searching the net suggests that the binaries should be compiled with -fPIC
to fix this issue.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22 (9 by maintainers)
Links to this issue
Commits related to this issue
- added WITH_IPP=OFF build flag in order to support x86 builds with android ndk versions >= 16. See https://github.com/opencv/opencv/issues/10229 for further details. — committed to letsdev/opencv by fabiankoebel 6 years ago
- Workarounds to make the RTDB testapp work with latest Android Studio. Using Android Studio 3.4.2 and Pixel 2 XL (Android 9, API 28) emulator, trying to compile the testapp produces the following erro... — committed to var-const/quickstart-cpp by var-const 5 years ago
Try adding this before “add_library()” (from the comment with workarounds):
@erikman
How did you build your application? (ndk-build / cmake from gradle / something else) Do you use OpenCV Java API in your application?
Anyway, there is workaround to build Android application library - don’t use OpenCV static libraries, use libopencv_java3.so instead:
But probably you will need to load libopencv_java3.so (via
System.loadLibrary()
) before application native library (not required on modern devices).Problem is related to visibility of IPPICV symbols in .a files: they should be “hidden” to prevent exporting of these symbols from the .so file. Can be workarounded via these linker flags:
Something like this:
I experienced the same issue when I upgraded Android Studio on MacOSX.
Downgrading from NDK16 to NDK14 temporarily solved the issue for me
To downgrade:
This package built with Android NDK r10e, so it may just not work with NDK 16 (we don’t test this). You need to rebuilt this package yourself with your target NDK 16 instead.
Mentioned flag doesn’t disable x86/x86_64 libraries (it disables IPP optimizations for x86 only - code may work slower on some workloads).
Any update on this? Have the same issue and downgrading is not really an option because I’m building on an external server with the latest NDK (v16) installed
I had the same issue and your solution @airman00 solved my problem. Thanks!