shekohex / flutterust

Flutter + Rust = :heart:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

linker error

4meta5 opened this issue · comments

This my output when I run cargo make

➜  flutterust git:(master) cargo make     
[cargo-make] INFO - cargo make 0.30.6
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: default
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: workspace
[cargo-make][1] INFO - External file not found or is not a file, skipping.
[cargo-make][1] INFO - Project: adder-ffi
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: default
[cargo-make][1] INFO - Profile: development
[cargo-make][1] INFO - Running Task: format
[cargo-make][1] INFO - Execute Command: "cargo" "fmt"
[cargo-make][1] INFO - Running Task: format-flow
[cargo-make][1] INFO - Running Task: pre-android
[cargo-make][1] INFO - Running Task: android-aarch64
[cargo-make][1] INFO - Execute Command: "cargo" "ndk" "--platform" "28" "--target" "aarch64-linux-android" "build"
   Compiling libc v0.2.69
   Compiling proc-macro2 v1.0.12
   Compiling unicode-xid v0.2.0
   Compiling cfg-if v0.1.10
   Compiling getrandom v0.1.14
   Compiling syn v1.0.18
   Compiling serde v1.0.106
   Compiling bitflags v1.2.1
   Compiling ppv-lite86 v0.2.6
   Compiling ryu v1.0.4
   Compiling log v0.4.8
   Compiling unicode-width v0.1.7
   Compiling ansi_term v0.11.0
   Compiling unicode-segmentation v1.6.0
   Compiling vec_map v0.8.1
   Compiling cbindgen v0.14.2
   Compiling itoa v0.4.5
   Compiling remove_dir_all v0.5.2
   Compiling strsim v0.8.0
   Compiling adder v0.1.0 (/Users/4meta5/flutter-bin/flutterust/native/adder)
   Compiling textwrap v0.11.0
   Compiling heck v0.3.1
   Compiling quote v1.0.4
   Compiling atty v0.2.14
   Compiling clap v2.33.0
   Compiling rand_core v0.5.1
   Compiling rand_chacha v0.2.2
   Compiling rand v0.7.3
   Compiling tempfile v3.1.0
   Compiling serde_derive v1.0.106
   Compiling toml v0.5.6
   Compiling serde_json v1.0.52
   Compiling adder-ffi v0.1.0 (/Users/4meta5/flutter-bin/flutterust/native/adder-ffi)
error: linker `/Users/4meta5/Library/Android/sdk/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android28-clang` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error

error: could not compile `adder-ffi`.

To learn more, run the command again with --verbose.
[cargo-make][1] ERROR - Error while executing command, exit code: 101
[cargo-make][1] WARN - Build Failed.
[cargo-make] ERROR - Error while executing command, exit code: 1
[cargo-make] WARN - Build Failed.

So I guess I need to configure/build/download that toolchain for the Android SDK.

Note: I followed the installation instructions and I did install the Rust compiler backend that the linker error specifies. I think the SDK doesn't have something it needs and that's what's throwing the error but I haven't been able to find installation instructions for Android SDK aarch64-linux-android28-clang with a quick search...

➜  flutterust git:(master) rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
info: component 'rust-std' for target 'aarch64-linux-android' is up to date
info: component 'rust-std' for target 'armv7-linux-androideabi' is up to date
info: component 'rust-std' for target 'x86_64-linux-android' is up to date
info: component 'rust-std' for target 'i686-linux-android' is up to date

Hi, this issue related that your $ANDROID_NDK_HOME pointing to the wrong place, you need first install the Android NDK after that you should set the $ANDROID_NDK_HOME to the root of the NDK tools; In Mac, it looks something like this

export $ANDROID_NDK_HOME="/Users/$USER/Library/Android/sdk/ndk/21.1.6352462"

the 21.1.6352462 part of the path is the current version of NDK installed.

after that everything should work normally 😄

I set it in my zshrc file like

export ANDROID_NDK_HOME="/Users/4meta5/Library/Android/sdk/ndk/21.1.6352462"

and now my error is

   Compiling adder-ffi v0.1.0 (/Users/4meta5/flutter-bin/flutterust/native/adder-ffi)
error: linker `/Users/4meta5/Library/Android/sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android28-clang` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error

error: could not compile `adder-ffi`.

To learn more, run the command again with --verbose.
[cargo-make][1] ERROR - Error while executing command, exit code: 101
[cargo-make][1] WARN - Build Failed.
[cargo-make] ERROR - Error while executing command, exit code: 1
[cargo-make] WARN - Build Failed.

but I'm very sure that this is due to failed installation of some assumed Android NDK feature. It will be good when I figure out what it is because I just did a default installation so I'm sure others will need to do whatever it is I need to do...

I'll follow the instructions on that link to try to install the specific version for the Android NDK next. I'll close this issue once I've figured it out.

so it works on ios when I run

cargo make ios && cargo make post-ios

I'll close this issue when I get it working with Android but I do suspect that this is really just the fault of my Android NDK installation config...