17 Compilation Guide
Juniper Gardiner edited this page 2025-09-04 20:01:27 +01:00

Compiling The Project

Linux

Ensure you have all the dependencies installed on your system, they may have different package names depending on the distribution:

  • cmake
  • make
  • Rust
  • gcc
  • pkg-config
  • libxcb-devel
  • fontconfig-devel (Only for graphs in tests, not necessary in production)
  • shaderc (Only for GPU support)
  • Appropriate vulkan drivers for your system (Only for GPU support)

Included in the project is a file named configure. Running this will compile the C libraries and place them under /build.

Alongside this, to compile and use the rust wrapper, enter the astra-api-rs directory and run:

LD_LIBRARY_PATH=../build cargo test --release --features "sigf32 avx2 avx512 gpu" -- --nocapture

Change the defined features as necessary. The setting of LD_LIBRARY_PATH can be removed if you have a system-wide installation of Astra API already.

Android

Ensure you have all the dependencies installed on your system:

  • cmake
  • make
  • Rust
  • gcc
  • pkg-config
  • libxcb-devel
  • fontconfig-devel (Only for graphs in tests, not necessary in production)
  • shaderc (Only for GPU support)
  • Appropriate vulkan drivers for your system (Only for GPU support)

Included in the project is a file named configure. Running this will compile the C libraries and place them under /build. You will most likely get an error as compiling the AVX libraries will fail on any non-x86 system.

You will need a more recent version of shaderc-rs to compile the project on Android, which you can find here by taking the latest commit. Under the project workspace, you'll need to apply the patch by changing Cargo.toml

[workspace]
resolver = "3"
members = ["astra-api-rs", "astra-gpu"]

[patch.crates-io]
shaderc-sys = { path = "path/to/shaderc-rs-android-fix/shaderc-sys" }

Alongside this, you'll need to modify shaderc-rs-android-fix/shaderc-sys/Cargo.toml to change the version to 0.8.3:

[package]
name = "shaderc-sys"
version = "0.8.3"
[...]

Once you've done this, if you're using Termux you can run the rust wrapper of the project with this slightly modified command (under astra-api-rs)

SHADERC_LIB_DIR=/data/data/com.termux/files/usr/lib LD_LIBRARY_PATH=../build cargo test --release --features "sigf32 gpu" -- --nocapture

Otherwise, you should be able to use the same command as on standard Linux systems.

MacOS

MacOS compilation is similar to Linux. Ensure you have the same dependencies, however, you will also need to install MoltenVK for GPU support.

If you don't want to install MoltenVK system-wide, you can put the dynamic libraries in the build directory along with the C binaries.

Alongside this, during Rust compilation, ensure LD_LIBRARY_PATH is a full file path, not a relative one, i.e:

LD_LIBRARY_PATH=/path/to/astra-api/build cargo test --release --features "sigf32 avx2 avx512 gpu" -- --nocapture

Windows

Windows currently isn't supported but the library theoretically works. In terms of functionality, Windows is supported - Just that compiling on Windows isn't, only cross compiling from a regular Linux system.

In order for the project to work on Windows, you need to download a couple dependencies:

  • cmake
  • Visual Studio and its C/C++ tools
  • Rust
  • Vulkan SDK (Only for GPU support)
  • Appropriate GPU drivers for your system (Only for GPU support)

Configure the project using cmake:

mkdir build
cd build
cmake -S ../ -B ./

And finally build it:

cmake --build build --config Release --parallel

Now, if you haven't installed the compiled files systemwide, you'll need to add it to your path:

$env:Path += ";C:/path/to/astra-api/build/Release"

Run the rust project, as you would on Linux, but with LD_LIBRARY_PATH omitted, changing the features to meet your needs:

cargo test --release --features "sigf32 avx2 avx512 gpu" -- --nocapture