Can't build RustDesk - Android

576 Views Asked by At

I tried to build RustDesk project following documentation at documentation - android build

After executing:

VCPKG_ROOT=/opt/vcpkg ANDROID_NDK_HOME=/opt/android-ndk-r22b flutter/ndk_arm64.sh

I cp-ed vcpkg and android-ndk-r22b from home to /opt to make sure that path is right

I'm getting this one error message:

[2023-01-13T09:59:47Z INFO  cargo_ndk::cli] Using NDK at path: /opt/android-ndk-r22b (ANDROID_NDK_HOME)
[2023-01-13T09:59:47Z INFO  cargo_ndk::cli] NDK API level: 21
[2023-01-13T09:59:47Z INFO  cargo_ndk::cli] Building targets: arm64-v8a
[2023-01-13T09:59:47Z INFO  cargo_ndk::cli] Building arm64-v8a (aarch64-linux-android)
warning: function `patch` is never used
   --> libs/hbb_common/src/config.rs:239:4
    |
239 | fn patch(path: PathBuf) -> PathBuf {
    |    ^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: `hbb_common` (lib) generated 1 warning
   Compiling rustdesk v1.2.0 (/home/mwitek/rustdesk)
error: failed to run custom build command for `rustdesk v1.2.0 (/home/mwitek/rustdesk)`

Caused by:
  process didn't exit successfully: `/home/mwitek/rustdesk/target/release/build/rustdesk-9caa4dac4ffa2754/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-link-search=/opt/vcpkg/installed/arm64-android/lib
  cargo:rustc-link-lib=oboe
  cargo:rustc-link-lib=c++
  cargo:rustc-link-lib=OpenSLES
  cargo:rerun-if-changed=src/flutter_ffi.rs

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failed to run build_runner for /home/mwitek/rustdesk/flutter: ', build.rs:108:56
  stack backtrace:
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

And to be honest I don't know how to get rid of it, I already tried to understand what is wrong from code-side but I can only find this section in build.rs:

fn install_oboe() {
    let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
    if target_os != "android" {
        return;
    }
    let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
    if target_arch == "x86_64" {
        target_arch = "x64".to_owned();
    } else if target_arch == "aarch64" {
        target_arch = "arm64".to_owned();
    } else {
        target_arch = "arm".to_owned();
    }
    let target = format!("{}-android", target_arch);
    let vcpkg_root = std::env::var("VCPKG_ROOT").unwrap();
    let mut path: std::path::PathBuf = vcpkg_root.into();
    path.push("installed");
    path.push(target);
    println!(
        "{}",
        format!(
            "cargo:rustc-link-search={}",
            path.join("lib").to_str().unwrap()
        )
    );
    println!("cargo:rustc-link-lib=oboe");
    println!("cargo:rustc-link-lib=c++");
    println!("cargo:rustc-link-lib=OpenSLES");
    // I always got some strange link error with oboe, so as workaround, put oboe.cc into oboe src: src/common/AudioStreamBuilder.cpp
    // also to avoid libc++_shared not found issue, cp ndk's libc++_shared.so to jniLibs, e.g.
    // ./flutter_hbb/android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so
    // let include = path.join("include");
    //cc::Build::new().file("oboe.cc").include(include).compile("oboe_wrapper");
}

But it doesn't look like anything for me

Also here is function that's generating exception:

fn gen_flutter_rust_bridge() {
    let llvm_path = match std::env::var("LLVM_HOME") {
        Ok(path) => Some(vec![path]),
        Err(_) => None,
    };
    // Tell Cargo that if the given file changes, to rerun this build script.
    println!("cargo:rerun-if-changed=src/flutter_ffi.rs");
    // settings for fbr_codegen
    let opts = lib_flutter_rust_bridge_codegen::Opts {
        // Path of input Rust code
        rust_input: "src/flutter_ffi.rs".to_string(),
        // Path of output generated Dart code
        dart_output: "flutter/lib/generated_bridge.dart".to_string(),
        // Path of output generated C header
        c_output: Some(vec!["flutter/macos/Runner/bridge_generated.h".to_string()]),
        // for other options lets use default
        llvm_path,
        ..Default::default()
    };
    // run fbr_codegen
    lib_flutter_rust_bridge_codegen::frb_codegen(opts).unwrap();
}

Where it's last line is the one that throws this error.

lib_flutter_rust_bridge_codegen::frb_codegen(opts).unwrap();

I know this question really specific but documentation and self-investigation does not helping.

Also my OS properties: Ubuntu 20.04 x64 [Freshly installed]

0

There are 0 best solutions below