Menu

how-to-cross-compile-chess-engines-with-rust

Archimedes

For these brief instructions, basic knowledge of the command line under Linux is required.

https://en.m.wikibooks.org/wiki/Linux_Guide/Using_the_shell

  1. Install Android NDK (for example to /opt/android-ndk).
  2. Add the following commands to the end of the .bashrc file in your home directory (Android NDK should be accessible from everywhere):
    export PATH=$PATH:/opt/android-ndk
    export PATH=$PATH:/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin
  3. Install required packages for Rust.
    apt-get update
    apt-get install build-essential clang curl
  4. Install Rust with the installer on https://rustup.rs/.
  5. Add the necessary targets.
    rustup target add aarch64-linux-android
    rustup target add armv7-linux-androideabi
    rustup target add i686-linux-android
    rustup target add x86_64-linux-android
  6. Create a file named "config.toml" in the home directory under .cargo with the following content:

    [target.aarch64-linux-android]
    linker = "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang"
    [target.armv7-linux-androideabi]
    linker = "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang"
    [target.i686-linux-android]
    linker = "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang"
    [target.x86_64-linux-android]
    linker = "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang"

  7. To compile for the different architectures, use the following commands:
    cargo build --release --target=aarch64-linux-android
    cargo build --release --target=armv7-linux-androideabi
    cargo build --release --target=i686-linux-android
    cargo build --release --target=x86_64-linux-android

To keep Rust up to date, run the rustup update command from time to time.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.