New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to cross-compile to Android #49
Comments
On Discord, @bkirwi pointed out you can use the $ export AR_aarch64_linux_android=$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar
$ export CC_aarch64_linux_android=$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang
$ export CXX_aarch64_linux_android=$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++
$ export BINDGEN_EXTRA_CLANG_ARGS=-I$NDK_HOME/sources/cxx-stl/llvm-libc++/include/
$ cargo build --target aarch64-linux-android
...
Compiling tflite v0.9.6
error: failed to run custom build command for `tflite v0.9.6`
Caused by:
process didn't exit successfully: `/home/michael/Documents/hotg-ai/rune/target/debug/build/tflite-e86bb924f15fa979/build-script-build` (exit status: 101)
--- stderr
/home/michael/Android/Sdk/ndk/22.1.7171670/sources/cxx-stl/llvm-libc++/include/typeinfo:222:16: error: reinterpret_cast from 'std::__type_info_implementations::__non_unique_arm_rtti_bit_impl::__type_name_t' (aka 'unsigned int') to 'size_t' (aka 'unsigned long') is not allowed
/home/michael/Android/Sdk/ndk/22.1.7171670/sources/cxx-stl/llvm-libc++/include/typeinfo:222:16: error: reinterpret_cast from 'std::__type_info_implementations::__non_unique_arm_rtti_bit_impl::__type_name_t' (aka 'unsigned int') to 'size_t' (aka 'unsigned long') is not allowed, err: true
thread 'main' panicked at 'Unable to generate STL bindings: ()', /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/tflite-0.9.6/build.rs:280:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed It seems like |
Did you solved it? |
Our solution was to create our own library which builds TensorFlow Lite and exposes just enough functionality to suit our needs while also (cross-)compiling to our target devices (Android, iOS, x86/ARM linux, x86 MacOS, Windows, etc.). |
I hope I'm not wrong to ask this here on such an old thread. But I have exactly the same blocker. I'm wondering if you happen to know what I would have to do to correct bindgen such that it targets a 64 bit platform? |
Sorry, I can't really help you there. We ended up moving away from the |
I don't want to be that guy who found a solution but left no update, so here goes: Take a look at my solution I would suggest to build tflitec-rs with a empty (except for the tflitec dependency) cargo project with all the settings configured for Android NDK 21. you'll need If you're really suffering, you can just grab the 64-bit libs here |
And very importantly, make sure you use rust
|
I'm trying to use the
tflite
crate on Android and iOS, but have been having issues getting it to compile. For some reason it doesn't look likebindgen
can find the C++ STL when it tries to generate bindings.Do you have any suggestions for resolving this?
Full Steps to Reproduce
First, clone the
tflite
crate:Next we need to add set up our environment for cross-compiling. This involves adding the
aarch64-linux-android
target and tellingcargo
where our C compiler and archiver is.I had the same issue using the
tf_v2.4.1
branch, although I needed to tellcc
where the C compiler and archiver is.The text was updated successfully, but these errors were encountered: