tensorflow: TF 1.4 build_all_android.sh fails with nsync.a

Running

NDK_ROOT="$HOME/Library/Android/sdk/ndk-bundle" bash $MAKEFILE_DIR/build_all_android.sh

results in this error

/Users/era/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: tensorflow/contrib/makefile/downloads/nsync/builds/armeabi-v7a.android.c++11/nsync.a: malformed archive header name at 8
/Users/era/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: tensorflow/contrib/makefile/downloads/nsync/builds/armeabi-v7a.android.c++11/nsync.a: malformed archive header name at 8
/Users/era/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: tensorflow/contrib/makefile/downloads/nsync/builds/armeabi-v7a.android.c++11/nsync.a: attempt to map 60 bytes at offset 67800 exceeds size of file; the file may be corrupt
collect2: error: ld returned 1 exit status
make: *** [.../tensorflow/tensorflow/contrib/makefile/gen/bin/benchmark] Error 1

NDK version 15c, Android Studio 3.0, macOS High Sierra 10.13.1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (13 by maintainers)

Most upvoted comments

It is the bug in tensorflow/contrib/makefile/compile_nsync.sh need to override AR with android’s AR , makefile=’ AR := ${NDK_ROOT}/toolchains/‘“$toolchain”’/prebuilt/‘“$android_os_arch”’/bin/‘“$bin_prefix”’-ar CC=${CC_PREFIX}
${NDK_ROOT}/toolchains/‘“$toolchain”’/prebuilt/‘“$android_os_arch”’/bin/‘“$bin_prefix”’-g++

This is another method I have confirmed. First, just compile it through build_all_android.sh script, then above err msg will print on the terminal. Second, just execute the script “compile_nsync.sh” in the makefile dir, a perfect libnsync.a and nsync.a will be there. Finally, we can link three libs: tensorflowe.a, protobuf.a, libnsync.a. God be with you!

I was basically able to remove the error after removing a particular nsync build folder corresponding to the architecture I was trying to build. For example, I had problem with armeabi and so, I removed ./tensorflow/contrib/makefile/downloads/nsync/builds/armeabi.android.c++11 folder and it built fine after that for that arch

Also, btw, used r14 of NDK.

I am also facing the same issue. Using the instructions on README for Makefile.

Configuration: MacOS Sierra 10.12.6 Android NDK r15c

android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: tensorflow/contrib/makefile/downloads/nsync/builds/armeabi-v7a.android.c++11/nsync.a: malformed archive header name at 8
android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: tensorflow/contrib/makefile/downloads/nsync/builds/armeabi-v7a.android.c++11/nsync.a: attempt to map 60 bytes at offset 68372 exceeds size of file; the file may be corrupt```

Any resolution to this?