You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenCV doesn't link on Android x86/x86_64 with ndk 16.0.4442984 with R_386_GOTOFF error. #10229
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.
Unzip and rename entire NDK folder to "ndk-bundle"
Replace NDK 16 with NDK 14 by replacing the "ndk-bundle" in your Android home folder (for me it was /Library/Android/sdk) with the "ndk-bundle" folder from Step 2
Reacted by Alexander Alekhin, millytwm, Jamie, Franko and sahilgargkis
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
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).
Reacted by Hannes Achleitner and Dzmitry Stabrouski
@alalek I've got same error while linking against OpenCV binaries I've built with recent NDK (16.1.4479499). So I don't think this is related to old NDK version.
Doning small google search before encoutering this thread, I've found this NDK issue which may be related:
Basically I'm getting Specified toolchain "arm-linux-androideabi-4.8" is missing in your NDK or broken. Please verify that your NDK is working or select another compiler toolchain. . Is there anything else I should change?
EDIT: after some struggle could pass that point and now it breaks after building for the first api level (android-14) with File "/Users/sergiomoura/repos/temp/opencv/modules/java/generator/gen_java.py", line 1602, in <module> import hdr_parser ImportError: No module named hdr_parser
Looks like this python module is not found. Would be really awesome that OpenCV could support ndk r16
To the maintainer of OpenCV: You do a awesome job, but Android platform needs some modernization, please merge any improvement PR to reduce such issues and let the devs concentrate to awesome project they do
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:
P.S. "don't work" is short for "I am getting the issue described in the subject", since we are already in this context. I sure can go to OpenCV forum, but I want to talk about this issue :D.
This issue is closed with the link on the patch with fix. It is merged into OpenCV "master" branch, so this issue is resolved.
It is still unclear that you trying to do (your exact steps). You should understand that we are not able to help (even not to fix, - many problems are related to "configuration issues") if we can't reproduce the issue.
Yep, I saw it's closed.
So to explain you what I am doing. I was building my application which is using OpenCV for android with NDK15c and all was good and pretty, till I updated to NDK16.0..., after that I got the same error this post was made for, and the version after (NDK16.1...) had the same issue. To solve I downgraded to NDK15c.
So my question was really easy :), is this related to NDK or to OpenCV, as I was thinking this is an NDK issue. It's okay, you replied to it in the second time, don't need to answer that.
So next really easy question, all I have to do is to update this file
I could build OpenCV
I was building my application which is using OpenCV for android
They are a different things really.
You probably have prebuilt OpenCV package without the fix (no releases yet with the fix). So you need to apply some workaronds to hack it. These workarounds depends on how you build your app:
do you use modern Android Studio with gradle?
is there JNI part of your app? do you use CMake or ndk-build (with .mk files)?
It is better to use android.toolchain.cmake from Android NDK (instead of OpenCV - like Android Studio does), but it doesn't resolve error from this issue.
Take a look on workarounds from this comment: #10229 (comment) or from this commit 5f9bb62 .
Activity
airman00 commentedon Dec 7, 2017
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:
https://developer.android.com/ndk/downloads/older_releases.html
hederguerreiro commentedon Dec 13, 2017
I had the same issue and your solution @airman00 solved my problem. Thanks!
sergiomarqmoura commentedon Dec 28, 2017
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
alalek commentedon Dec 28, 2017
Current workaround is disabling IPP (affects x86/x86_64 platforms): add "-DWITH_IPP=OFF" CMake option into build script.
sergiomarqmoura commentedon Dec 28, 2017
@alalek I see, but in practice even with that flag we currently have to remove the x86 and x86_64 ABIs right?
alalek commentedon Dec 28, 2017
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).
barzto commentedon Dec 28, 2017
@alalek I've got same error while linking against OpenCV binaries I've built with recent NDK (16.1.4479499). So I don't think this is related to old NDK version.
Doning small google search before encoutering this thread, I've found this NDK issue which may be related:
android/ndk#556
sergiomarqmoura commentedon Dec 29, 2017
Hey @erikman , I tried to build OpenCV 3.2.0 using NDK r16b (darwin), with the changes you added on the PR for open CV to be able to build with that version, and still getting some issues. To build, I followed these instructions: http://yangchao.me/post/build-opencv-android-sdk/
Basically I'm getting
Specified toolchain "arm-linux-androideabi-4.8" is missing in your NDK or broken. Please verify that your NDK is working or select another compiler toolchain.. Is there anything else I should change?EDIT: after some struggle could pass that point and now it breaks after building for the first api level (android-14) with
File "/Users/sergiomoura/repos/temp/opencv/modules/java/generator/gen_java.py", line 1602, in <module> import hdr_parser ImportError: No module named hdr_parserLooks like this python module is not found. Would be really awesome that OpenCV could support ndk r16
hannesa2 commentedon Dec 29, 2017
To the maintainer of OpenCV: You do a awesome job, but Android platform needs some modernization, please merge any improvement PR to reduce such issues and let the devs concentrate to awesome project they do
sergiomarqmoura commentedon Dec 29, 2017
Also, @erikman did you rebuild OpenCV using your previous NDK but with the
"-DWITH_IPP=OFF"on the buildscript or using the newer r16 NDK?Yes, the first comment states this:
alalek commentedon Jan 4, 2018
@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:
erikman commentedon Jan 10, 2018
@sergiomarquesmoura: my patches for building with r16 are here: #10288, @alalek's solution is nicer though :)
alexandrucaraus commentedon Jan 20, 2018
I could build OpenCV only with NDK 15c, the two versions after that 16.0... and 16.1... to current date do not work. Is this an NDK or OpenCV issue?
alalek commentedon Jan 20, 2018
Usage questions should go to Users OpenCV Q/A forum: http://answers.opencv.org
Posts "don't work" with lack of required information are completely useless, consider doing minor investigations and providing related details (including version which you get and what you are doing with samples of exact commands).
P.S. You should use ndk-16.config with NDK16.
alexandrucaraus commentedon Jan 20, 2018
Thanks for the config!
P.S. "don't work" is short for "I am getting the issue described in the subject", since we are already in this context. I sure can go to OpenCV forum, but I want to talk about this issue :D.
alalek commentedon Jan 20, 2018
This issue is closed with the link on the patch with fix. It is merged into OpenCV "master" branch, so this issue is resolved.
It is still unclear that you trying to do (your exact steps). You should understand that we are not able to help (even not to fix, - many problems are related to "configuration issues") if we can't reproduce the issue.
alexandrucaraus commentedon Jan 20, 2018
Yep, I saw it's closed.
So to explain you what I am doing. I was building my application which is using OpenCV for android with NDK15c and all was good and pretty, till I updated to NDK16.0..., after that I got the same error this post was made for, and the version after (NDK16.1...) had the same issue. To solve I downgraded to NDK15c.
So my question was really easy :), is this related to NDK or to OpenCV, as I was thinking this is an NDK issue. It's okay, you replied to it in the second time, don't need to answer that.
So next really easy question, all I have to do is to update this file
/Users/alex/Projects/Android/DocSign/opencv/src/sdk/native/jni/android.toolchain.cmake
with this changes?
90cc3f6
alalek commentedon Jan 20, 2018
They are a different things really.
You probably have prebuilt OpenCV package without the fix (no releases yet with the fix). So you need to apply some workaronds to hack it. These workarounds depends on how you build your app:
.mkfiles)?It is better to use
android.toolchain.cmakefrom Android NDK (instead of OpenCV - like Android Studio does), but it doesn't resolve error from this issue.Take a look on workarounds from this comment: #10229 (comment) or from this commit 5f9bb62 .
alexandrucaraus commentedon Jan 20, 2018
Yes, I use the prebuilt package for Android (v 3.3.0).
The contents of CMakeLists.txt:
alalek commentedon Jan 20, 2018
Try adding this before "add_library()" (from the comment with workarounds):
alexandrucaraus commentedon Jan 20, 2018
Yep, works like a charm.
Thanks a ton!
milly1228 commentedon Mar 5, 2018
airman00 you save my time , thanks a lot
added WITH_IPP=OFF build flag in order to support x86 builds with and…
Workarounds to make the RTDB testapp work with latest Android Studio.