As we have multiple target platform in Rust, I've a library that is required to be compiled for both Android
and Raspberry
I fixed the linker
of each target in the /.cargo/config
file as below:
[target.arm-linux-androideabi]
linker = "/home/rust/android-18-toolchain/bin/arm-linux-androideabi-clang"
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc-8"
And I was able to build the library as below 2 commands:
, and and we can build executable/library for each target by one of the below 2 methods (not sure if there are other ways):
~$cargo build --target=arm-linux-androideabi
~$cargo build --target=armv7-unknown-linux-gnueabihf
I aware I can add the [build]
in the /.cargo/config
if I want to build for single platform, as shown here by writting:
[build]
target = "arm-linux-androideabi"
to avoid using $cargo build --target=arm-linux-androideabi
I tried to add the other target
, so it became like:
[build]
target = "armv7-unknown-linux-gnueabihf"
target = "wasm32-unknown-unknown"
[target.arm-linux-androideabi]
linker = "/home/rust/android-18-toolchain/bin/arm-linux-androideabi-clang"
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc-8"
But got the below error upon trying ~$cargo build
:
hyousef@DESKTOP-KPD1Q5Q:/mnt/d/raspberry$ cargo build
error: could not load Cargo configurationCaused by:
could not parse TOML configuration in/home/hyousef/.cargo/config
Caused by:
could not parse input as TOMLCaused by:
duplicate key:target
for key `build