Closed Flocksserver closed 5 years ago
Hmm, looks like the crfsuite-sys lib dependency is the problem? As a Mobile Developer I am not that familiar with c and rust 🙈 Do you know how to deal with it? Thanks!
Hi @Flocksserver !
Cross compiling rust is usually easy, as long as this is pure rust you're compiling. As soon as you start compiling some C code, it get complicated. In this case you didn't tell to the build scripts of backtrace-sys
, bzip2-sys
and crfsuite-sys
which C compiler to use so they tryied to guess the name it should have based on the used rustc tuple and failed.
You can use environment variables to setup that (TARGET_CC
, or better CC_armv7-linux-androideabi
) but it can quickly be tedious as the C compiler is not the only thing that may need configuring.
At snips we developed a tool to do all that configuration for you it called dinghy. We recently added the support for android-ndk r19 (ie without standalone toolchains)
You don't need to configure anything in the .cargo/config
to use it, a simple cargo dinghy --platform auto-android-armv7 build
should do the job. You may have to pass an env var to tell dinghy where your ndk is located (ANDROID_NDK_HOME
) but it should find it it is in a standard location.
snips-nlu-rs
is one of the crates we use to develop dinghy as we need it in our android sdk
Thanks @fredszaq for your kindful answer! That does make sense :) Unfortunately it does not work...
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: armv7--linux-android
Thread model: posix
InstalledDir:
ignoring nonexistent directory "lib/clang/10.0.0/include"
ignoring nonexistent directory "/Users/marcelkaufmann/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/include"
#include "..." search starts here:
#include <...> search starts here:
/Users/marcelkaufmann/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/8.0.2/include
/Users/marcelkaufmann/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/local/include
/Users/marcelkaufmann/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include
End of search list.
/Users/marcelkaufmann/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
/Users/marcelkaufmann/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found, err: true
The asm/types.h file is located in sysroot/usr/include/arm-linux-androideabi
and not in the search locations... Some sources say with another build system I can extend the CMakeLists.txt file to include directories
include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
How is that possible with dinghy? Should I ask this question in the dinghy repo? Is there a complete knowledge gap or a misunderstanding on my side? I would be very pleased if you can give me (one last time) another helpful hint. Best regards
Hi @Flocksserver can you include a little more context in you log ? ie full output of cargo clean && cargo dinghy --platform auto-android-armv7 build
make sure you don't have anything regarding the configuration of the armv7-linux-androideabi
target in your cargo config as it can interfere with dinghy own's config.
Do you have the same problem when trying to build directly snips-nlu-rs ?
# cargo --version
cargo 1.32.0 (8610973aa 2019-01-02)
# cargo-dinghy --version
dinghy 0.4.8
Do you have the same problem when trying to build directly snips-nlu-rs ?
Yes - the same
make sure you don't have anything regarding the configuration of the
armv7-linux-androideabi
target in your cargo config
I am sure I have no cargo config. Neither in the project dir nor in the users "home" dir
```
cargo dinghy --platform auto-android-armv7 build
INFO cargo_dinghy > Targeting platform 'auto-android-armv7' and device '
Thanks for the logs ! a few things to try next:
brew install llvm
) and in your $PATH as crfsuite won't build without it.@fredszaq Hero 🥇 Oh WOW seriously? After upgrading to mojave two month ago or so... seemingly the llvm permissions/installation got broken. But with these error logs pointing on an android ndk path error I was not expecting that.... 😅 Thanks a lot for your time and thoughts!
Hey guys, I would like to compile an android lib with rust, jni and your snips-nlu-lib. Without the snips-nlu-lib my android lib compiles as expected. My cargo config looks like:
I am not using the standalone android toolchain but the standard ndk as mentioned in https://developer.android.com/ndk/guides/other_build_systems because of my ndk version r19. The lib as well as the JNI connection works:
Finished release [optimized] target(s) in 0.14s
After adding
snips-nlu-lib = { git = "https://github.com/snipsco/snips-nlu-rs", branch = "master" }
I find
Do you have any suggestion what the problem is? Why does the compiler search for arm-linux-androideabi-clang and where? And why after adding your library? Thanks :)