tflite-rs
tflite-rs copied to clipboard
Compilation failure: fatal error: 'memory' file not found
When adding tflite
as a dependency to my Cargo file I get the following build error:
error: failed to run custom build command for `tflite v0.9.7`
Caused by:
process didn't exit successfully: `~project/target/release/build/tflite-819bacb90d6fa43f/build-script-build` (exit status: 101)
--- stderr
csrc/stl_wrapper.hpp:1:10: fatal error: 'memory' file not found
thread 'main' panicked at 'Unable to generate STL bindings: ClangDiagnostic("csrc/stl_wrapper.hpp:1:10: fatal error: 'memory' file not found\n")', ~.cargo/registry/src/index.crates.io-6f17d22bba15001f/tflite-0.9.7/build.rs:301:10
I tried multiple target architectures, but that does not seem to matter. I believe my project is otherwise fairly standard, any pointers on how to solve this issue?
What is your compile target? I'm getting the same issues trying to compile to Web assembly using any of the following targets
wasm32-unknown-wasi
wasm32-unknown-unknown
wasm32-unknown-emscripten
Seems like these standard libraries refuse to compile into wasm.
I managed to get the project to build using cargo build --target x86_64-unknown-linux-gnu
, sadly it doesn't really help me for what I'm trying to do
aarch64-linux-android
I suggest using clang-15 & gcc-11.
I am also trying to compile for android trying to use the advice of @MichaelMcCulloch here https://github.com/boncheolgu/tflite-rs/issues/49#issuecomment-1328050608
I am compiling using this command: cargo ndk --bindgen --target=aarch64-linux-android build
Adding environment variables as advised here: https://github.com/MichaelMcCulloch/WhisperVoiceKeyboard/blob/787047c2760960e40f38b87c5951fb714e45f45d/app/src/main/rust/.vscode/cargoNdkEnv.sh
I have progressed a bit further from the 'memory' file not found error, adding paths to other header files that are also not found via BINDGEN_EXTRA_CLANG_ARGS_AARCH64_LINUX_ANDROID
.
Currently I am stuck with this error:
/mnt/c/Users/.../AppData/Local/Android/Sdk/ndk/26.2.11394342/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found.
@boncheolgu I see you suggest using clang-15 & gcc-11, can you confirm that android compiles correctly in linux using this version combination?
I have:
Android (11349228, based on r487747e) clang version 17.0.2 (https://android.googlesource.com/toolchain/llvm-project d9f89f4d16663d5012e5c09495f3b30ece3d2362)
Target: aarch64-unknown-linux-android21
Thread model: posix
InstalledDir: C:/Users/GarethEgerton/AppData/Local/Android/Sdk/ndk/26.2.11394342/toolchains/llvm/prebuilt/windows-x86_64/bin
With clang version 17 installed via Android Studio in windows.
Does anybody have advice on what is the best way to proceed, the main issue is that header files cannot be found. The files do exist however it seems the pathing to them is either different or not recognized. I am not sure whether this is due to different clang version / due to installation of clang via Android Studio on windows having different relative paths to Linux. Is this potentially a quick fix or requires some change to the rust build script? Also can we only expect the specific version suggested to compile correctly, any ideas are most welcome :)
Just curious. I see you are using ndk 26.2.11394342
, whereas I am using 21.4.7075529
in the commit you referenced and 25.1.8937393
on main. This comment suggests sticking with ndk <= 25 || rustc <= 1.67.1. Is there a reason you need 26? Which version of rustc are you using?
@MichaelMcCulloch thanks for coming back to me, I am using rustc 1.78. We have a wider project using 26.2.11394342 and this rust version which ideally we would not have to deviate from. My understanding from https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html was that versions >= 1.6.8 and >= 25 should theoretically work together, although I am not sure.