For compiling for Android, we need to generate linker, ad call it in the .cargo/config
, I got the required linkers, saved them in the project root
, and called them in the /.cargo/config
as:
[target.x86_64-linux-android]
ar = "<project_root>/ndk_for_rust/x86_64/bin/x86_64-linux-android-ar"
linker = "<project_root>/ndk_for_rust/x86_64/bin/x86_64-linux-android-clang"
And everything moved smoothly.
Now i need to create another project, so to avoid having multiple copies of my ndk_for_rust
folder, I added to the path $HOME/.bash_profile
as:
export NDK_FOR_RUST_HOME=/usr/local/ndk_for_rust
And tried to call it in the .cargo/config
as:
[target.x86_64-linux-android]
ar = "${NDK_FOR_RUST_HOME}/ndk_for_rust/x86_64/bin/x86_64-linux-android-ar"
linker = "${NDK_FOR_RUST_HOME}/ndk_for_rust/x86_64/bin/x86_64-linux-android-clang"
But got the below error upon running cargo build --target x86_64-linux-android --release
:
error: linker `/Users/h_ajsf/IdeaProjects/rust_app02/${NDK_FOR_RUST_HOME}/x86_64/bin/x86_64-linux-android-clang` not found
|
= note: No such file or directory (os error 2)
Is there a way to use a linker
to a location outside my project root, so I avoid having multiple copies?