Git Product home page Git Product logo

cargo-ndk's Introduction

cargo-ndk - Build Rust code for Android

CI Minimum supported Rust version: 1.73

This cargo extension handles all the environment configuration needed for successfully building libraries for Android from a Rust codebase, with support for generating the correct jniLibs directory structure.

Installing

cargo install cargo-ndk

You'll also need to install all the toolchains you intend to use. Simplest way is with the following:

rustup target add \
    aarch64-linux-android \
    armv7-linux-androideabi \
    x86_64-linux-android \
    i686-linux-android

Modify as necessary for your use case.

Usage

If you have installed the NDK with Android Studio to its default location, cargo ndk will automatically detect the most recent NDK version and use it. This can be overriden by specifying the path to the NDK root directory in the ANDROID_NDK_HOME environment variable.

Examples

Building a library for 32-bit and 64-bit ARM systems

cargo ndk -t armeabi-v7a -t arm64-v8a -o ./jniLibs build --release

This specifies the Android targets to be built (ordinary triples are also supported), the output directory to use for placing the .so files in the layout expected by Android, and then the ordinary flags to be passed to cargo.

Example

Linking against and copying libc++_shared.so into the relevant places in the output directory

Create a build.rs in your project with the following:

use std::{env, path::{Path, PathBuf}};

fn main() {
    if env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" {
        android();
    }
}

fn android() {
    println!("cargo:rustc-link-lib=c++_shared");

    if let Ok(output_path) = env::var("CARGO_NDK_OUTPUT_PATH") {
        let sysroot_libs_path =
            PathBuf::from(env::var_os("CARGO_NDK_SYSROOT_LIBS_PATH").unwrap());
        let lib_path = sysroot_libs_path.join("libc++_shared.so");
        std::fs::copy(
            lib_path,
            Path::new(&output_path)
                .join(&env::var("CARGO_NDK_ANDROID_TARGET").unwrap())
                .join("libc++_shared.so"),
        )
        .unwrap();
    }
}

Controlling verbosity

Add -v or -vv as you ordinarily would after the cargo command.

Providing environment variables for C dependencies

cargo-ndk derives which environment variables to read the same way as the cc crate.

cargo-ndk-specific environment variables

These environment variables are exported for use in build scripts and other downstream use cases:

  • CARGO_NDK_ANDROID_PLATFORM: the Android platform API number as an integer (e.g. 21)
  • CARGO_NDK_ANDROID_TARGET: the Android name for the build target (e.g. armeabi-v7a)
  • CARGO_NDK_OUTPUT_PATH: the output path as specified with the -o flag
  • CARGO_NDK_SYSROOT_PATH: path to the sysroot inside the Android NDK
  • CARGO_NDK_SYSROOT_TARGET: the target name for the files inside the sysroot (differs slightly from the standard LLVM triples)
  • CARGO_NDK_SYSROOT_LIBS_PATH: path to the libraries inside the sysroot with the given sysroot target (e.g. $CARGO_NDK_SYSROOT_PATH/usr/lib/$CARGO_NDK_SYSROOT_TARGET)

Printing the environment

Sometimes you just want the environment variables that cargo-ndk configures so you can, say, set up rust-analyzer in VS Code or similar.

If you want to source it into your bash environment:

source <(cargo ndk-env)

PowerShell:

cargo ndk-env --powershell | Out-String | Invoke-Expression

Rust Analyzer and anything else with JSON-based environment handling:

For configuring rust-analyzer, add the --json flag and paste the blob into the relevant place in the config.

Supported hosts

  • Linux
  • macOS (x86_64 and arm64)
  • Windows

Local development

git clone and then install the crate with cargo:

cargo install --path .

Similar projects

  • cargo-cocoapods - for building .a files for all Apple platforms, and bundling for CocoaPods

License

This project is licensed under either of

at your option.

cargo-ndk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cargo-ndk's Issues

cargo ndk fails due to pkg-config issue

Hi all,

I think I've read every suggestion on the internet at this point to no avail, so I'm hoping I can get some help here.

Repro

git clone https://github.com/banool/aclip.git
cd aclip/frontend/native
cargo ndk -t armeabi-v7a -o ../android/app/src/main/jniLibs build

The code in question: https://github.com/banool/aclip.

Relevant env:

PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig/
LDFLAGS=-L/opt/homebrew/opt/[email protected]/lib
CPPFLAGS=-I/usr/local/opt/[email protected]/include
CFLAGS=-I/opt/homebrew/opt/[email protected]/include
ANDROID_NDK_HOME=/Users/dport/Library/Android/sdk/ndk

Output

Running the above gives me this: https://gist.github.com/d2564965bbd5e4d8bf72c3132c87255f.

Some thoughts on what's going on here:

I have set the libunwind stuff suggested here: http://cjycode.com/flutter_rust_bridge/template/setup_android.html. That helped with the gcc error in the second gist here, but I've still got the ssl and crypto errors.

Any tips on how to proceed would be very much appreciated.

Thanks!

Copy all .so files instead of the ones just generated.

We have multiple ffi modules in our project we compile for different gradle modules.
This code

cargo-ndk/src/cli.rs

Lines 386 to 396 in 8478e58

let so_files = match fs::read_dir(&dir) {
Ok(dir) => dir
.filter_map(Result::ok)
.map(|x| x.path())
.filter(|x| x.extension() == Some(OsStr::new("so")))
.collect::<Vec<_>>(),
Err(e) => {
log::error!("{} {:?}", e, dir);
std::process::exit(1);
}
};

is copying all the .so files in the target directories. We end up having so files from previous build because of that.
The copy method should just target the files we generated from the build instead.

-D clippy flag is passed to check instead

It's currently not possible to use clippy's -D flag with through cargo-ndk, because the flag instead ends up being passed to check, which doesn't recognise it.
This isn't a huge issue and can be workes around fairly easily, but it would still be nice to be able to use the flag directly.

[BUG] can't find crate for `core`

I am getting the following error while generating builds:

cargo ndk -o ../android/app/src/main/jniLibs build
[2022-10-30T11:03:44Z INFO  cargo_ndk::cli] Using NDK at path: /Users/xxxx/Library/Android/sdk/ndk/22.1.7171670 (ANDROID_HOME)
[2022-10-30T11:03:44Z INFO  cargo_ndk::cli] NDK API level: 21
[2022-10-30T11:03:44Z INFO  cargo_ndk::cli] Building targets: armeabi-v7a, arm64-v8a
[2022-10-30T11:03:44Z INFO  cargo_ndk::cli] Building armeabi-v7a (armv7-linux-androideabi)
   Compiling autocfg v1.1.0
   Compiling cfg-if v1.0.0
   Compiling libc v0.2.133
   Compiling scopeguard v1.1.0
   Compiling crossbeam-utils v0.8.11
   Compiling once_cell v1.15.0
   Compiling adler v1.0.2
   Compiling proc-macro2 v1.0.43
   Compiling unicode-ident v1.0.4
   Compiling quote v1.0.21
error[E0463]: can't find crate for `core`
  |
  = note: the `armv7-linux-androideabi` target may not be installed
  = help: consider downloading the target with `rustup target add armv7-linux-androideabi`

cargo-ndk version: 2.12.2

I even tried to run rustup target add armv7-linux-androideabi but no luck
My OS is macOS Monterey M1 Pro

Fail to compile openssl

RANLIB is not automatically set by cargo ndk.

This issue can be fixed by manually setting RANLIB to /path/to/llvm-ranlib

log.txt

Only invoke cargo metadata for desired target(s)

Unlike most other cargo tools, cargo metadata counter-intuitively defaults to including all targets. This means that with the current logic, cargo-ndk ends up processing (and thus downloading dependencies for) all targets even though the user has specifically called out the targets they want to build for. Specifically, in the MetadataCommand invocation here

let metadata = match MetadataCommand::new().exec() {

cargo-ndk should probably always specify --filter-platform to each of the specified targets via MetadataCommand::other_options. Unfortunately --filter-platform only takes a single target triple, so you'd have to run metadata once per platform, but that's probably what you'd want to do anyway, since the dependency closure can vary between platforms.

Alternatively, if you aren't using any of the dependency metadata info, and are just invoking cargo metadata in order to get information about the workspace, you can call MetadataCommand::no_deps, which also makes the cargo metadata invocation a fair bit faster!

NDK 23 beta: Build fails with `unable to find library -lgcc`

I'm trying to build a new project, however when running the command cargo ndk -t aarch64-linux-android -o ./jniLibs build --release, but I end up with an error;

error: linking with `/home/<user>/Android/Sdk/ndk/23.0.7421159/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang` failed: exit status: 1
  |
  = note: ld: error: unable to find library -lgcc
          clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

Should cargo-ndk work when building c dependencies with cc?

For instance building: https://github.com/rust-lang/backtrace-rs/

cargo ndk --target=armv7-linux-androideabi --android-platform 21 -- build

produces:

OPT_LEVEL = Some("0")
TARGET = Some("armv7-linux-androideabi")
HOST = Some("x86_64-apple-darwin")
CC_armv7-linux-androideabi = None
CC_armv7_linux_androideabi = None
TARGET_CC = None
CC = None
CFLAGS_armv7-linux-androideabi = None
CFLAGS_armv7_linux_androideabi = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running: "arm-linux-androideabi-clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=armv7-linux-androideabi" "-Wall" "-Wextra" "-E" "src/android-api.c"

--- stderr

error occurred: Failed to find tool. Is arm-linux-androideabi-clang installed?

Cargo ndk ignores --manifest-path

Hi there :)

First of all thanks for this nice helper!

Since the last update we face a problem, since we are building the cargo project via Gradle from within Android-Studio and use the cargo "--manifest-path" option to specify the location of the Rust project. Since the CLI now uses cargo-metadata and sets the manifest path explicitly on the line below, we face an error.

let metadata = match MetadataCommand::new().manifest_path("./Cargo.toml").exec() {

Currently, we, as a workaround, change working directory, but I would suggest checking and using the --manifest-path option.

The CLI should check if the cargo option --manifest-path is set, and use it for all calls to cargo.

Provide workaround for crates that uses bindgen

A lot of crates use https://github.com/rust-lang/rust-bindgen to create bindings for C structures. The problem is current versions of bindgen don't provide correct target for invoked clang during cross-compilation. As a result cargo-ndk can't compile such crates.

Here is workaround to set BINDGEN_EXTRA_CLANG_ARGS variable and provide target here. For example, BINDGEN_EXTRA_CLANG_ARGS="--target=aarch64-linux-android"

It would be nice if this workaround be applied by cargo-ndk

Support bin executable artifacts

Hi!
This is not really a problem, but here is my use case.

I'd like to ship a Rust executable within my Android application. Unfortunately, from API 29, the only way to make that possible is to put the executable inside the lib/<abi> folder, and thus must be named like lib<...>.so.
Rust crate names cannot contain dots ., so my build process consists in building the project (example), and then renaming it to libexample.so, and finally move it to the target abi folder.

It would be cool if there was a flag in cargo-ndk (let's say --bin or --type <bin|lib>) which is aware of this, which would prepend lib and append .so to the artifcact name instead of logging an error.

I guess the implementation would look like this:
First, get the current package (is there a nicer way than the following?);
Then, iterate over the build targets and so on.

// inside cli::run

let package = metadata.packages.iter().find(|package| package.manifest_path.eq(cargo_manifest)).unwrap();
for build_target in &package.targets {
    let is_shared_lib = build_target.crate_types.contains(&"bin".into());
    println!("Is {} a shared library? {}", build_target.name, is_shared_lib);
    // etc
}
// etc

However, I feel like there should be a major refactoring in order to appropriately support this, and I'm not sure if the required effort is worthy. Just my two cents.

Bundling forces with `cargo-apk`?

Hi! I'm one of the maintainers for android-ndk-rs, and occasionally use cargo-ndk to build a crate for Android that doesn't need the surrounding apk. Unfortunately cargo-ndk doesn't work with the R23 NDK due to an issue that has already been solved in ndk-build. I also couldn't get ANDROID_NDK_ROOT to work, presumably because cargo-ndk only recognizes ANDROID_NDK_HOME.

ndk-build is our crate for cross-compiling native binaries and creating apks, and is exactly focused at being reusable in ie. cargo-ndk. Since we're both pursuing the same goal and doing the exact same thing, would you be open to see if we can unify our projects and relieve/share the maintenance "burden"? I envision to start with simply comparing ndk-build to cargo-ndk and integrate any features that are missing, followed by migrating cargo-ndk over to ndk-build. We can optionally take cargo-ndk into the android-ndk-rs tree being another "frontend" CLI to ndk-build just like cargo-apk, if both parties are open to this.

Looking forward to your opinion!

Feature Request: copy built so files to src/main/jniLibs

I wish cargo ndk command had a feature to copy the built .so files to the default load path of an Android project (src/main/jniLibs/<arch_name>) after building.
This feature would make it a "one-stop plugin for people writing Android libraries in Rust"!

One problem to solve is the CLI:

  • Add an option to cargo ndk build? Or a new subcommand such as cargo ndk install?
  • How to specify the path to Android project directory? There can be several directory structures for such projects (one with several "app" directories, one whose "app" directory and Rust project directory are separate, etc.)

After I made arrangements for those problems with you, I'll implement it.

executable file is not striped in release build

[2021-10-15T04:12:24Z INFO  cargo_ndk::cli] Copying libraries to ./jniLibs...
[2021-10-15T04:12:24Z ERROR cargo_ndk::cli] No .so files found in path "/Users/weishu/dev/github/memo/target/aarch64-linux-android/release"
[2021-10-15T04:12:24Z ERROR cargo_ndk::cli] Did you set the crate-type in Cargo.toml to include 'cdylib'?
[2021-10-15T04:12:24Z ERROR cargo_ndk::cli] For more info, see <https://doc.rust-lang.org/cargo/reference/cargo-targets.html#library>.

Allow specifying more standard target triples

Hi,

I've been using cargo ndk for some time now and one thing that has been a little awkward at times is that cargo ndk uses ABI names (such as armeabi-v7a) as "target" names instead of standard triples like "armv7-linux-androideabi".

It's also a little misleading that the argument is referred to as a target and documented to be a "triple" (command line --help docs say: "triple for the target(s)")

One place where this is a bit awkward to work with is in defining github CI workflows where it can be desirable to setup a workflow matrix that would build a combination of operating systems, stable/nightly rust compilers and combination of targets. It's awkward when most other tools/components are using standard target triples but but cargo ndk uses ABI names and so it becomes necessary to map from one to the other.

Would you be open to updating cargo ndk so that the -t/--target arguments would accept target triples like armv7-linux-androideabi and aarch64-linux-android? I would think it could be ok for cargo ndk to continue also accepting ABI names to maintain backwards compatibility.

Readme reads like garbage

The readme is kinda garbage and if someone could reorganise it with their own strong opinions that would be lovely.

"No archive symbol table" Linker error

I ran:

cargo ndk --platform 29 --target x86_64-linux-android build

And got this:

error: linking with `/Users/username/Library/Android/sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android29-clang` failed: exit code: 1
...

  = note: /Users/username/Library/Android/sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: ssl: no archive symbol table (run ranlib)
          /Users/username/Library/Android/sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: crypto: no archive symbol table (run ranlib)
          clang: error: linker command failed with exit code 1 (use -v to see invocation)         

What is the problem?

My $NDK_HOME:
/Users/username/Library/Android/sdk/ndk/21.3.6528147/

Not passing rustflags to build commands.

I am on Windows, trying to compile a program with tokio (unstable enabled) for Android.
This builds successfully when using cargo build, but I can't seem to get cargo ndk ... to include the required --cfg tokio_unstable flags when building.

Steps to reproduce:
In my <project_root>/.cargo/config.toml file:

[build]
rustflags = ["--cfg", "tokio_unstable"]

When I run this command:
cargo ndk -t x86_64 -o ./out build -v

I am not seeing --cfg tokio_unstable in the build commands, and my program fails to compile since it's using the 'unstable' features of tokio.

Support for rust-analyzer and/or cargo ndk check for intellisense

Would you be willing to add support for rust-analyzer, that is, support for cargo check? Currently I'm having the following problem: rust-lang/rust-analyzer#12335

Basically,

cargo ndk -t x86_64 check --workspace --message-format=json --target x86_64-linux-android --package=glium_codename --package=libcodename
[2022-05-21T03:35:56Z INFO  cargo_ndk::cli] Using NDK at path: /opt/android-sdk-linux/ndk/22.1.7171670
[2022-05-21T03:35:56Z INFO  cargo_ndk::cli] NDK API level: 21
[2022-05-21T03:35:56Z INFO  cargo_ndk::cli] Building targets: x86_64
[2022-05-21T03:35:56Z INFO  cargo_ndk::cli] Building x86_64 (x86_64-linux-android)
error: specifying multiple `--target` flags requires `-Zmultitarget`
[2022-05-21T03:35:56Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2022-05-21T03:35:56Z INFO  cargo_ndk::cli] 
[2022-05-21T03:35:56Z INFO  cargo_ndk::cli]     rustup target install x86_64-linux-android

if I take out --target x86_64-linux-android it works. Basically it does not support multiple targets but in this case it should be the same target. I'm not familiar with cargo internals so I don't know what's happening here, but rust-analyzer always adds --target x86_64-linux-android so maybe we should support it instead of -t x86_64? I don't know how but it makes sense

Stripping fails for ARMv7

When I try to run cargo ndk -t armeabi-v7a -t arm64-v8a -t x86 -t x86_64 -o (pwd)/jniLibs -v build --release I always get an error at the last strip where cargo ndk tries to strip the binary.

I found out that (at least for MacOS) the binary name is arm-linux-androideabi-strip whereas cargo ndk uses the armv7-linux-androideabi triple for ARMv7.

Wondering whether this is something MacOS specific or fails on all platforms. I'm currently using NDK version 21.4.7075529 so that might also be something that changed in the NDK over time.

UPDATE: I installed the Android SDK with NDK in a clean Docker image to check it out for linux systems. Same situation there.

Build broken after v2 update

Hi, so I adapted my build invocation to cargo ndk v2, but now I'm getting this error:

error: failed to run custom build command for `backtrace-sys v0.1.35`

Caused by:
  process didn't exit successfully: `target/release/build/backtrace-sys-592314409b0beb5b/build-script-build` (exit code: 1)
  --- stdout
  OPT_LEVEL = Some("3")
  TARGET = Some("aarch64-linux-android")
  HOST = Some("x86_64-apple-darwin")
  CC_aarch64-linux-android = Some("toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang")
  CFLAGS_aarch64-linux-android = None
  CFLAGS_aarch64_linux_android = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  running: "toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-linux-android" "-Wall" "-Wextra" "-E" "src/android-api.c"

  --- stderr


  error occurred: Failed to find tool. Is `aarch64-linux-android21-clang` installed?

IIRC, this used to be fixed in older cargo ndk by adding '--lib', but now it seems to not make any difference. Any ideas?

[Feature] Enable specification of `--features`

Hi :)

First of all, thanks for providing this crate!

I'm currently trying to create a common crate that's shared between two different architectures, an esp32 Rust project and an Android project via FFI.

Some dependencies in this crate need to be hidden behind feature flags, as they would otherwise interfere with the esp32's dependency resolution, resulting in compilation errors due to non-std issues.

This feature flag now works perfectly fine on the esp32 side, but I couldn't find a way in cargo-ndk to specify feature flags for crates. Could you imagine adding such a feature or having such a feature added to your project :)?

Best regards

Target not found [aarch64-linux-android]

Using the new mac silicon as the host, I'm trying to cargo make the repo here. Unfortunately, once it gets to the step cargo ndk --platform 28 --target aarch64-linux-android build, I get the following error message:

invalid argument to option `--target`: Unsupported target: 'aarch64-linux-android'

I have already installed the target via rustup, and it has proven to work in other contexts just fine. However, when in the cargo ndk context, this error message occurs.

Retain debug info?

Hi thanks for the lib! The output .so file seems to be stripped. I wonder how can I remain debug info? Thanks!

"cargo install cargo-ndk" fails

> cargo install cargo-ndk
    Updating crates.io index
  Installing cargo-ndk v2.2.0
   Compiling proc-macro2 v1.0.24
   Compiling unicode-xid v0.2.1
   Compiling syn v1.0.60
   Compiling memchr v2.3.4
   Compiling serde_derive v1.0.123
   Compiling serde v1.0.123
   Compiling ryu v1.0.5
   Compiling libc v0.2.86
   Compiling once_cell v1.5.2
   Compiling serde_json v1.0.62
   Compiling log v0.4.14
   Compiling cfg-if v1.0.0
   Compiling smallvec v1.6.1
   Compiling semver-parser v0.7.0
   Compiling regex-syntax v0.6.22
   Compiling pct-str v1.1.0
   Compiling quick-error v1.2.3
   Compiling itoa v0.4.7
   Compiling os_str_bytes v2.4.0
   Compiling percent-encoding v2.1.0
   Compiling termcolor v1.1.2
   Compiling eieio v1.0.0
   Compiling home v0.5.3
   Compiling thread_local v1.1.3
   Compiling iref v1.4.3
   Compiling humantime v1.3.0
error[E0008]: cannot bind by-move into a pattern guard
   --> /Users/asmirnov/.cargo/registry/src/github.com-1ecc6299db9ec823/iref-1.4.3/src/reference/mod.rs:331:10
    |
331 |             (Some(a), Some(b)) if a == b => (),
    |                   ^ moves value into pattern guard

error[E0008]: cannot bind by-move into a pattern guard
   --> /Users/asmirnov/.cargo/registry/src/github.com-1ecc6299db9ec823/iref-1.4.3/src/reference/mod.rs:331:19
    |
331 |             (Some(a), Some(b)) if a == b => (),
    |                            ^ moves value into pattern guard

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0008`.
error: Could not compile `iref`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-ndk v2.2.0`, intermediate artifacts can be found at `/var/folders/_l/kl9pdj2x50v7416j8htb6w740000gn/T/cargo-install5xVgV1`

Caused by:
  build failed

NDK r25 does not handle quoted parameters to clang on Windows

Running cargo ndk -t x86_64 -p 33 build gives me this error:

[2023-03-11T17:32:51Z INFO  cargo_ndk::cli] Using NDK at path: C:\AndroidNDK (ANDROID_NDK_HOME)
[2023-03-11T17:32:51Z INFO  cargo_ndk::cli] NDK API level: 33
[2023-03-11T17:32:51Z INFO  cargo_ndk::cli] Building targets: x86_64
[2023-03-11T17:32:51Z INFO  cargo_ndk::cli] Building x86_64 (x86_64-linux-android)
   Compiling and2 v0.1.0 (C:\Users\Glenn\and2)
error: linking with `C:\AndroidNDK\toolchains\llvm\prebuilt\windows-x86_64\bin\x86_64-linux-android33-clang.cmd` failed: exit code: 255
  |
  = note: "C:\\AndroidNDK\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android33-clang.cmd" "-Wl,--version-script=C:\\Users\\Glenn\\AppData\\Local\\Temp\\rustcMmyczo\\list" "-m64" "C:\\Users\\Glenn\\AppData\\Local\\Temp\\rustcMmyczo\\symbols.o" "C:\\Users\\Glenn\\and2\\target\\x86_64-linux-android\\debug\\deps\\and2.220y3l223trvteix.rcgu.o" "C:\\Users\\Glenn\\and2\\target\\x86_64-linux-android\\debug\\deps\\and2.3izm99ra9qa3p8id.rcgu.o" "-Wl,--as-needed" "-L" "C:\\Users\\Glenn\\and2\\target\\x86_64-linux-android\\debug\\deps" "-L" "C:\\Users\\Glenn\\and2\\target\\debug\\deps" "-L" "C:\\Users\\Glenn\\and2\\target\\cargo-ndk\\libgcc-workaround" "-L" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib" "-Wl,-Bstatic" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libstd-3b76298062fcbb41.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libpanic_unwind-5c79ad5020a8a376.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libobject-c856ab6f9f61a0c8.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libmemchr-4330e4945024bd31.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libaddr2line-b743fb28f7e6f36b.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libgimli-3c967a14752063ee.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_demangle-de83573183ce509d.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libstd_detect-189990c033015975.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libhashbrown-4ac8e97124e072c7.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libminiz_oxide-c58c6d1c5b304afc.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libadler-4112d160f12e0da0.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_std_workspace_alloc-e50526c393c6b479.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libunwind-c0afb47c69be5adb.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libcfg_if-36bd188b5238bf89.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\liblibc-9c1c158f10c4615e.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\liballoc-ae67f691b53af35a.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_std_workspace_core-e9e3e381106ad9fb.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libcore-e3d2ffae725503a0.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libcompiler_builtins-7de08890edb9a78a.rlib" "-Wl,-Bdynamic" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib" "-o" "C:\\Users\\Glenn\\and2\\target\\x86_64-linux-android\\debug\\deps\\liband2.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: --version-script=C:\Users\Glenn\AppData\Local\Temp\rustcMmyczo\list"" was unexpected at this time.


error: could not compile `and2` due to previous error
[2023-03-11T17:33:05Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2023-03-11T17:33:05Z INFO  cargo_ndk::cli]
[2023-03-11T17:33:05Z INFO  cargo_ndk::cli]     rustup target install x86_64-linux-android

I'm on a x86_64 Windows 10 machine, and I have installed both Android SDK and Android NDK.

/usr/include/linux/errno.h:1:10: fatal error: 'asm/errno.h' file not found

I got

  --- stderr
  /usr/include/linux/errno.h:1:10: fatal error: 'asm/errno.h' file not found
  /usr/include/linux/errno.h:1:10: fatal error: 'asm/errno.h' file not found, err: true
  thread 'main' panicked at 'Binding generation failed.: ()', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rusty_ffmpeg-0.8.1/build.rs:322:22

when trying to compile my project. Aren't you forgetting to pass some header locations? Because the NDK has errno.h at sysroot/usr/include/aarch64-linux-android/asm

[BUG] `--bindgen` flag has misleading behavior

I was using cargo-ndk with custom BINDGEN_EXTRA_CLANG_ARGS enviroment variable for so long, but it seems that new versions cargo-ndk overwrites that environment variable whether you pass --bindgen or omit it.

In my opinion, this commit in this PR must be reverted (in other words, else block must be deleted). --bindgen flag must be an opt-in flag and it mustn't change behavior if you omit it.

I can create a PR for this if you like.

NDK 23 missing *-ar tools

I'm getting the following error because NDK 23 doesn't seem to have the *-ar tools available. Using NDK 22 is fine.

error occurred: Failed to find tool. Is /Users/<user>/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar installed?

build is failed,

cargo ndk -t armeabi-v7a -t arm64-v8a -o ./jniLibs build --release

[2022-02-14T08:52:36Z INFO  cargo_ndk::cli] Using NDK at path: /Users/xxxx/Library/Android/sdk/ndk/21.4.7075529
[2022-02-14T08:52:36Z INFO  cargo_ndk::cli] NDK API level: 21
[2022-02-14T08:52:36Z INFO  cargo_ndk::cli] Building targets: armeabi-v7a, arm64-v8a
[2022-02-14T08:52:36Z INFO  cargo_ndk::cli] Building armeabi-v7a (armv7-linux-androideabi)
   Compiling cfg-if v1.0.0
   Compiling regex-syntax v0.6.25
   Compiling jni-sys v0.3.0
   Compiling bytes v1.1.0
error[E0463]: can't find crate for `core`
  |
  = note: the `armv7-linux-androideabi` target may not be installed
  = help: consider downloading the target with `rustup target add armv7-linux-androideabi`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` due to previous error
warning: build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `std`
  |
  = note: the `armv7-linux-androideabi` target may not be installed
  = help: consider downloading the target with `rustup target add armv7-linux-androideabi`

error: build failed
[2022-02-14T08:52:37Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2022-02-14T08:52:37Z INFO  cargo_ndk::cli] 
[2022-02-14T08:52:37Z INFO  cargo_ndk::cli]     rustup target install armv7-linux-androideabi

Is the "Rust+Android NDK" approach suitable and production-ready compared with the traditional C++ approach? i.e. Can I use it in real-world app in production environment?

Hi thanks for this lib! I wonder whether the "Rust+Android NDK" approach is suitable and production-ready compared with the traditional C++ approach? i.e. Can I use it in real-world app in production environment?

For example, will there be performance issues for performance-critical programs? Will the generated size be too big? Will there be hidden traps (because the whole toolchain is not that mature)?

Bundling with "libc++_shared.so"

Hi!

Ive been trying to use cargo ndk with a bigger rust library.
The library is generating Java JNI bindings through a generator called "flapigen". (So its not a direct cmake project)
After building the APK with gradlew aR, which triggers gradlew jar (For making the Java side of the generated bindings) and a gradle task for running cargo ndk -t ${arch} -o ${libsPath} build --release.

Yea.. a bit of a trip :D But in the end the APK gets generated, and properly links with the generated jar.
When i install the APK, it also loads the native library correctly, however, one of the native parts needs libc++_shared.so (for i think a rust dependency, im in a bit over my head!).

According to .. the internet it should compile with that .so when i set APP_STL:=c++_shared in Application.mk, or

android {
    defaultConfig {
        ...
        externalNativeBuild {
            ndkBuild {
                arguments  "-DAPP_STL=c++_shared", "-DANDROID_TOOLCHAIN=clang"
            } 
        }
    }
}

However, inspecting the APK, it doesnt have it incuded.

The error: Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found: needed by /data/app/~~1wFPIY2YxMCnGcnEq7pBpA==/org.example-MjRM-ZMHEp1x9fjGfZEjrA==/base.apk!/lib/arm64-v8a/libexample_java.so in namespace classloader-namespace.
Ive tried building on NDK 20, 21 and 23, and targeting SDK 27, 28 and 29 to no avail.
Using gradle-6.7.1, if it makes a difference

        classpath 'com.android.tools.build:gradle:4.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"

Any pointers you can give me?
Thank you!

Cargo.lock is missing

Hello!

Cargo.lock should be present in the repository due to cargo-ndk being a "bin" project, however it is ignored via .gitignore.

This is also important for reproducible builds since --locked flag fails when Cargo.lock is not found.

I propose committing Cargo.lock to the repository and removing it from .gitignore. Happy to submit a PR :)

Error: failed to run custom build command for ring v0.16.20

Hi, I'm trying to build Rust code for Android and run into some issues.
I installed Android Studio with the NDK and the Rust toolchains as mentioned in the README on my macOS.

When I run following commands:

git clone https://github.com/iotaledger/wallet.rs
cd wallet.rs/bindings/java/iota-wallet-java/native
cargo ndk -t armeabi-v7a -t arm64-v8a -o ./jniLibs build --release

I run into these errors:

samuel@MacBook-Pro-von-Samuel native % cargo ndk -t armeabi-v7a -t arm64-v8a -o ./jniLibs build --release
[2022-10-12T10:24:06Z INFO  cargo_ndk::cli] Using NDK at path: /Users/samuel/Library/Android/sdk/ndk/25.1.8937393 (Standard Location)
[2022-10-12T10:24:06Z INFO  cargo_ndk::cli] NDK API level: 21
[2022-10-12T10:24:06Z INFO  cargo_ndk::cli] Building targets: armeabi-v7a, arm64-v8a
[2022-10-12T10:24:06Z INFO  cargo_ndk::cli] Building armeabi-v7a (armv7-linux-androideabi)
   Compiling ring v0.16.20
   Compiling hidapi v1.4.2
   Compiling ledger-transport v0.10.0
   Compiling ed25519-zebra v3.0.0
   Compiling x25519-dalek v1.1.1
   Compiling futures v0.3.24
   Compiling librocksdb-sys v0.8.0+7.4.4
   Compiling hyper v0.14.20
   Compiling impl-codec v0.6.0
   Compiling derive_builder v0.11.2
   Compiling primitive-types v0.11.1
   Compiling iota-crypto v0.14.3
   Compiling iota-crypto v0.12.1
error: failed to run custom build command for `hidapi v1.4.2`

Caused by:
  process didn't exit successfully: `/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/release/build/hidapi-8cf9ee9f1de0b5ec/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBUDEV_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'Unable to find libudev: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.', /Users/samuel/.cargo/registry/src/github.com-1ecc6299db9ec823/hidapi-1.4.2/build.rs:57:54
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `ring v0.16.20`

Caused by:
  process didn't exit successfully: `/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/release/build/ring-f65ca07f5663cdb8/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("3")
  TARGET = Some("armv7-linux-androideabi")
  HOST = Some("aarch64-apple-darwin")
  CC_armv7-linux-androideabi = Some("/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang")
  CFLAGS_armv7-linux-androideabi = Some(" -D__ANDROID_API__=21")
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")

  --- stderr
  running "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "include" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-DNDEBUG" "-c" "-o/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/ring-a9400e8a94a9aef4/out/aesv8-armx-linux32.o" "/Users/samuel/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux32.S"
  <built-in>:389:9: error: '__ANDROID_API__' macro redefined [-Werror,-Wmacro-redefined]
  #define __ANDROID_API__ 21
          ^
  <built-in>:381:9: note: previous definition is here
  #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
          ^
  1 error generated.
  thread 'main' panicked at 'execution failed', /Users/samuel/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:656:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The following warnings were emitted during compilation:

warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from rocksdb/cache/cache_key.cc:13:
warning: In file included from rocksdb/util/hash.h:26:
warning: rocksdb/util/fastrange.h:62:5: error: unknown type name '__uint128_t'
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:     ^
warning: rocksdb/util/fastrange.h:62:24: error: use of undeclared identifier '__uint128_t'
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:                        ^
warning: rocksdb/util/fastrange.h:62:35: error: expected ';' at end of declaration
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:                                   ^
warning:                                   ;
warning: 1 warning generated.
warning: 1 warning and 3 errors generated.
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: In file included from <built-in>:444:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:435:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: 1 warning generated.
warning: In file included from rocksdb/cache/sharded_cache.cc:16:
warning: In file included from rocksdb/util/hash.h:26:
warning: rocksdb/util/fastrange.h:62:5: error: unknown type name '__uint128_t'
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:     ^
warning: rocksdb/util/fastrange.h:62:24: error: use of undeclared identifier '__uint128_t'
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:                        ^
warning: rocksdb/util/fastrange.h:62:35: error: expected ';' at end of declaration
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:                                   ^
warning:                                   ;
warning: 1 warning and 3 errors generated.
warning: 1 warning generated.
warning: 1 warning generated.
warning: 1 warning generated.
warning: In file included from rocksdb/db/arena_wrapped_db_iter.cc:10:
warning: In file included from rocksdb/db/arena_wrapped_db_iter.h:13:
warning: In file included from rocksdb/db/db_impl/db_impl.h:22:
warning: In file included from rocksdb/db/column_family.h:18:
warning: In file included from rocksdb/db/memtable_list.h:16:
warning: In file included from rocksdb/db/memtable.h:20:
warning: In file included from rocksdb/db/kv_checksum.h:37:
warning: In file included from rocksdb/util/hash.h:26:
warning: rocksdb/util/fastrange.h:62:5: error: unknown type name '__uint128_t'
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:     ^
warning: rocksdb/util/fastrange.h:62:24: error: use of undeclared identifier '__uint128_t'
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:                        ^
warning: rocksdb/util/fastrange.h:62:35: error: expected ';' at end of declaration
warning:     __uint128_t wide = __uint128_t{range} * hash;
warning:                                   ^
warning:                                   ;
warning: 1 warning generated.
warning: 1 warning generated.
warning: 1 warning and 3 errors generated.

error: failed to run custom build command for `librocksdb-sys v0.8.0+7.4.4`

Caused by:
  process didn't exit successfully: `/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/release/build/librocksdb-sys-ae33167b6990370e/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=rocksdb/
  TARGET = Some("armv7-linux-androideabi")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-apple-darwin")
  CXX_armv7-linux-androideabi = Some("/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++")
  CXXFLAGS_armv7-linux-androideabi = Some(" -D__ANDROID_API__=21")
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CXX_armv7-linux-androideabi = Some("/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++")
  CXXFLAGS_armv7-linux-androideabi = Some(" -D__ANDROID_API__=21")
  CRATE_CC_NO_DEFAULTS = None
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/cache.o" "-c" "rocksdb/cache/cache.cc"
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/cache_entry_roles.o" "-c" "rocksdb/cache/cache_entry_roles.cc"
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/cache_reservation_manager.o" "-c" "rocksdb/cache/cache_reservation_manager.cc"
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/clock_cache.o" "-c" "rocksdb/cache/clock_cache.cc"
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/fast_lru_cache.o" "-c" "rocksdb/cache/fast_lru_cache.cc"
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/cache_key.o" "-c" "rocksdb/cache/cache_key.cc"
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/lru_cache.o" "-c" "rocksdb/cache/lru_cache.cc"
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/compressed_secondary_cache.o" "-c" "rocksdb/cache/compressed_secondary_cache.cc"
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from rocksdb/cache/cache_key.cc:13:
  cargo:warning=In file included from rocksdb/util/hash.h:26:
  cargo:warning=rocksdb/util/fastrange.h:62:5: error: unknown type name '__uint128_t'
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=    ^
  cargo:warning=rocksdb/util/fastrange.h:62:24: error: use of undeclared identifier '__uint128_t'
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=                       ^
  cargo:warning=rocksdb/util/fastrange.h:62:35: error: expected ';' at end of declaration
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=                                  ^
  cargo:warning=                                  ;
  cargo:warning=1 warning generated.
  cargo:warning=1 warning and 3 errors generated.
  exit status: 0
  exit status: 1
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/sharded_cache.o" "-c" "rocksdb/cache/sharded_cache.cc"
  running: "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/db/arena_wrapped_db_iter.o" "-c" "rocksdb/db/arena_wrapped_db_iter.cc"
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=In file included from <built-in>:444:
  cargo:warning=<command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
  cargo:warning=#define __ANDROID_API__ 21
  cargo:warning=        ^
  cargo:warning=<built-in>:435:9: note: previous definition is here
  cargo:warning=#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
  cargo:warning=        ^
  cargo:warning=1 warning generated.
  exit status: 0
  cargo:warning=In file included from rocksdb/cache/sharded_cache.cc:16:
  cargo:warning=In file included from rocksdb/util/hash.h:26:
  cargo:warning=rocksdb/util/fastrange.h:62:5: error: unknown type name '__uint128_t'
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=    ^
  cargo:warning=rocksdb/util/fastrange.h:62:24: error: use of undeclared identifier '__uint128_t'
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=                       ^
  cargo:warning=rocksdb/util/fastrange.h:62:35: error: expected ';' at end of declaration
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=                                  ^
  cargo:warning=                                  ;
  cargo:warning=1 warning and 3 errors generated.
  exit status: 1
  cargo:warning=1 warning generated.
  cargo:warning=1 warning generated.
  exit status: 0
  exit status: 0
  cargo:warning=1 warning generated.
  exit status: 0
  cargo:warning=In file included from rocksdb/db/arena_wrapped_db_iter.cc:10:
  cargo:warning=In file included from rocksdb/db/arena_wrapped_db_iter.h:13:
  cargo:warning=In file included from rocksdb/db/db_impl/db_impl.h:22:
  cargo:warning=In file included from rocksdb/db/column_family.h:18:
  cargo:warning=In file included from rocksdb/db/memtable_list.h:16:
  cargo:warning=In file included from rocksdb/db/memtable.h:20:
  cargo:warning=In file included from rocksdb/db/kv_checksum.h:37:
  cargo:warning=In file included from rocksdb/util/hash.h:26:
  cargo:warning=rocksdb/util/fastrange.h:62:5: error: unknown type name '__uint128_t'
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=    ^
  cargo:warning=rocksdb/util/fastrange.h:62:24: error: use of undeclared identifier '__uint128_t'
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=                       ^
  cargo:warning=rocksdb/util/fastrange.h:62:35: error: expected ';' at end of declaration
  cargo:warning=    __uint128_t wide = __uint128_t{range} * hash;
  cargo:warning=                                  ^
  cargo:warning=                                  ;
  cargo:warning=1 warning generated.
  exit status: 0
  cargo:warning=1 warning generated.
  exit status: 0
  cargo:warning=1 warning and 3 errors generated.
  exit status: 1

  --- stderr


  error occurred: Command "/Users/samuel/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang++" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "rocksdb/include/" "-I" "rocksdb/" "-I" "rocksdb/third-party/gtest-1.8.1/fused-src/" "-I" "lz4/lib/" "-I" "." "-std=c++17" "-Wsign-compare" "-Wshadow" "-Wno-unused-parameter" "-Wno-unused-variable" "-Woverloaded-virtual" "-Wnon-virtual-dtor" "-Wno-missing-field-initializers" "-Wno-strict-aliasing" "-Wno-invalid-offsetof" "-DLZ4=1" "-DNDEBUG=1" "-DOS_ANDROID" "-DROCKSDB_PLATFORM_POSIX" "-DROCKSDB_LIB_IO_POSIX" "-DROCKSDB_SUPPORT_THREAD_LOCAL" "-DHAVE_UINT128_EXTENSION=1" "-o" "/Users/samuel/IdeaProjects/wallet.rs/bindings/java/iota-wallet-java/native/target/armv7-linux-androideabi/release/build/librocksdb-sys-e14f86f0e82b425d/out/rocksdb/cache/cache_key.o" "-c" "rocksdb/cache/cache_key.cc" with args "armv7a-linux-androideabi21-clang++" did not execute successfully (status code exit status: 1).


[2022-10-12T10:24:09Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2022-10-12T10:24:09Z INFO  cargo_ndk::cli] 
[2022-10-12T10:24:09Z INFO  cargo_ndk::cli]     rustup target install armv7-linux-androideabi

I tried to include different libs and tested the setup on Ubuntu, but continue to run into the same [failed to run custom build command for ring v0.16.20`](https://stackoverflow.com/questions/72461117/error-failed-to-run-custom-build-command-for-ring-v0-16-20)
issue.

Any idea what I'm missing? Many thanks for the help.

Path changed for ndk bundle?

I just reinstalled Android studio and the entire sdk last night, and the option for the ndk install seems to have changed from previous versions.

When I was running "cargo ndk" it was failing as it was looking for "ndk-bundle" in the android sdk directory.

My newly installed ndk was at ~/Library/Android/sdk/ndk/$version_number/ instead of sdk/ndk-bundle

To workaround it, I softlinked one to the other and then "cargo ndk" worked just fine.

FYI

Error copying targets when using profile dev

When using profile dev like so cargo ndk build --profile dev

It seems that the target directory created is called debug and not dev but cargo-ndk looks for dev directory :

[2023-03-22T15:55:18Z ERROR cargo_ndk::cli] No such file or directory (os error 2) "rust-repository/target/aarch64-linux-android/dev"

Wrong tag

Hello!

I realized v2.15.5 was tagged today. However, it should be v2.12.5 instead. I just wanted to let you know.

You can fix this by running:

git fetch --tags
git tag -d v2.15.5
git push --delete origin v2.15.5
git tag v2.12.5 0f6487b93a54d92603b56ea85d613009ed76b6e2
git push --tags

When custom cargo profile is specified ndk tries to copy from invalid directory

Hello, first of all thanks for amazing project! I wanted to hug you all after hitting the ndk and gcc linking issue... <3

I've found the problem when trying to use cargo's custom profiles. The output directory changes and I get the following error after successful compilation:

2022-08-08T11:08:52Z INFO  cargo_ndk::cli] Copying libraries to ./target/jniLibs...
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /Users/username/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-ndk-2.11.0/src/cli.rs:343:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To reproduce one should create custom profile in Cargo.toml:

[profile.release-space-optimized]
inherits = "release"
strip = true  # Automatically strip symbols from the binary.
opt-level = "z"  # Optimize for size.
lto = true  # Enable link time optimization
codegen-units = 1  # Reduce parallel code generation units
panic = "abort"

And call cli interface while specifying custom profile:

cargo ndk \
    -t armeabi-v7a \
    -t arm64-v8a \
    -o ./target/jniLibs build --profile release-space-optimized

cargo will output files to directory: target/triple/{name_of_the_profile}

Slash in sysroot paths for windows

When building an android from windows with the --bindgen flag, an incorrect path gets into clang.

C:UsershumanAppDataLocalAndroidsdkndk22.1.7171670toolchainsllvmprebuiltwindows-x86_64sysroot/usr/include

instead of

C:/Users/human/AppData/Local/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuil/twindows-x86_64/sysroot/usr/include

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.