Jim Rhodes
Jim Rhodes

Reputation: 5095

Input/output error using Android ndk-build

Using Android NDK R10E, I am trying to build a shared library for all supported ABI's and I am getting the following error for some but not all ABI's:

[armeabi] SharedLibrary : libMyLib.so /home/user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld:
fatal error: /home/user/source/MyLib/obj/local/armeabi/libMyLib.so: Input/output error

The project successfully builds for arm64-v8a, mips and mips64 but fails with the above error for armeabi, armeabi-v7a, x86 and x86_64.

I have a static library project and another shared library project and they both build successfully for all 7 ABI's.

If I compare the contents of obj/local/ for an ABI that builds and one that does not, they both contain all the same files except for libMyLib.so.

Upvotes: 1

Views: 1807

Answers (2)

tvlada
tvlada

Reputation: 21

Same issue happened to me in r15c.
The fix was to copy android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.bfd over ld.
I had to copy it because I could not easily find a way to specify this flag to CMake to use it while detecting the compiler features.

Upvotes: 0

Dan Albert
Dan Albert

Reputation: 10509

The difference between those two sets of ABIs is that the failing ones link using ld.gold and the working ones use ld.bfd.

Two things to try:

  • Use the 4.9 toolchain. It hopefully has the bug fix.
  • If that doesn't work, you can add -fuse-ld=bfd to your ldflags to use bfd even on the architectures that default to gold.

Upvotes: 1

Related Questions