Loki-RS Build Guide
March 11, 2026 · View on GitHub
This guide provides step-by-step instructions for building Loki-RS on different platforms.
Table of Contents
Linux Build
Prerequisites
Required Tools
-
Rust Toolchain
# Install Rust using rustup (recommended) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env # Verify installation rustc --version cargo --version -
System Dependencies
# Debian/Ubuntu sudo apt-get update sudo apt-get install -y build-essential pkg-config libssl-dev # Fedora/RHEL/CentOS sudo dnf install -y gcc openssl-devel # Arch Linux sudo pacman -S base-devel openssl
Optional: Development Tools
# Install clippy (linter) and rustfmt (formatter)
rustup component add clippy rustfmt
# Install cargo-audit (security audit)
cargo install cargo-audit
Build Steps
-
Clone the Repository
git clone https://github.com/Neo23x0/Loki-RS.git cd Loki-RS -
Build Release Version
cargo build --releaseMain binary:
target/release/lokiUtility binary:target/release/loki-util -
Fetch Signatures
./target/release/loki-util updateThis downloads the latest signatures to
./signatures. -
Build Debug Version (Optional)
cargo buildBinary will be at:
target/debug/loki -
Run Tests
cargo test -
Code Quality Checks
# Format code cargo fmt # Lint code cargo clippy # Security audit cargo audit
Build Output
- Debug build:
target/debug/loki(~10-20 MB, unoptimized, with debug symbols) - Release build:
target/release/loki(~5-10 MB, optimized, stripped)
Cross-Platform Build
Prerequisites
-
Install Rust Cross-Compilation Targets
# Add target for Windows (x86_64) rustup target add x86_64-pc-windows-gnu # Add target for Windows (ARM64) rustup target add aarch64-pc-windows-msvc # Add target for macOS (x86_64) rustup target add x86_64-apple-darwin # Add target for macOS (ARM64/Apple Silicon) rustup target add aarch64-apple-darwin # Add target for Linux (ARM64) rustup target add aarch64-unknown-linux-gnu -
Install Cross-Compilation Tools
For Windows builds:
# Debian/Ubuntu sudo apt-get install -y mingw-w64 # Fedora sudo dnf install -y mingw64-gcc # Arch Linux sudo pacman -S mingw-w64-gccFor macOS builds:
- Requires macOS SDK (only available on macOS)
- Or use
osxcross(complex setup)
For Linux ARM builds:
# Debian/Ubuntu sudo apt-get install -y gcc-aarch64-linux-gnu # Fedora sudo dnf install -y gcc-aarch64-linux-gnu
Build Commands
# Build for Windows (from Linux)
cargo build --release --target x86_64-pc-windows-gnu
# Build for Windows ARM64 (from Windows)
cargo build --release --target aarch64-pc-windows-msvc
# Build for macOS x86_64 (from macOS)
cargo build --release --target x86_64-apple-darwin
# Build for macOS ARM64 (from macOS)
cargo build --release --target aarch64-apple-darwin
# Build for Linux ARM64
cargo build --release --target aarch64-unknown-linux-gnu
Cross-Compilation Notes
- Windows x86_64 (
x86_64-pc-windows-gnu): Requiresmingw-w64toolchain. - Windows ARM64 (
aarch64-pc-windows-msvc): Build on Windows with Visual Studio C++ build tools (MSVC/ARM64 libraries). - macOS: Cross-compilation from Linux is complex. Best done on macOS itself or using CI/CD.
- ARM: Requires appropriate cross-compiler toolchain.
Windows Build
Prerequisites
-
Install Rust
- Download and run: https://rustup.rs/
- Or use:
winget install Rustlang.Rustup
-
Install Visual Studio Build Tools
- Download: https://visualstudio.microsoft.com/downloads/
- Install "Desktop development with C++" workload
- Or install "Build Tools for Visual Studio"
-
Install Git
- Download: https://git-scm.com/download/win
Build Steps
-
Open Developer Command Prompt
- Start Menu → Visual Studio → Developer Command Prompt
- Or use PowerShell/CMD with Visual Studio environment
-
Clone and Build
git clone https://github.com/Neo23x0/Loki-RS.git cd Loki-RS cargo build --release -
Binary Location
target\release\loki.exe
Alternative: Using WSL
If you have Windows Subsystem for Linux (WSL):
# In WSL
sudo apt-get update
sudo apt-get install -y build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cd /mnt/c/path/to/Loki-RS
cargo build --release
macOS Build
Prerequisites
-
Install Xcode Command Line Tools
xcode-select --install -
Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env -
Install Homebrew (optional, for additional tools)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Build Steps
# Clone repository
git clone https://github.com/Neo23x0/Loki-RS.git
cd Loki-RS
# Build release
cargo build --release
# Binary location
./target/release/loki
Apple Silicon (M1/M2/M3) Notes
- Rust automatically detects ARM64 architecture
- No special configuration needed
- Use
aarch64-apple-darwintarget if explicitly needed:cargo build --release --target aarch64-apple-darwin
Release Builds
Creating Release Binaries
-
Clean Build
cargo clean cargo build --release -
Strip Binary (reduce size)
# Linux strip target/release/loki # macOS strip target/release/loki # Windows (using strip from MinGW or Visual Studio) strip target/release/loki.exe -
Verify Binary
# Check binary info file target/release/loki # Test run ./target/release/loki --version
Release Package Structure
For distribution, create a package with:
loki-release-v2.0.0/
├── loki (or loki.exe)
├── README.md
├── LICENSE
└── signatures/
├── yara/ (YARA rules from YARA Forge)
└── iocs/ (optional custom IOC files)
Automated Release Builds
See .github/workflows/release.yml for automated release builds on Git tags.
Troubleshooting
Common Issues
1. "linker cc not found"
Solution:
# Debian/Ubuntu
sudo apt-get install build-essential
# Fedora
sudo dnf install gcc
# macOS
xcode-select --install
2. "OpenSSL not found"
Solution:
# Debian/Ubuntu
sudo apt-get install libssl-dev pkg-config
# Fedora
sudo dnf install openssl-devel
# macOS (with Homebrew)
brew install openssl
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
3. "Permission denied" when running binary
Solution:
chmod +x target/release/loki
4. "Signatures not found"
Solution:
# Use loki-util to download signatures
./loki-util update
# Or manually create structure and download
mkdir -p ./signatures/yara ./signatures/iocs
# Download YARA rules from YARA Forge and optionally add custom IOC files
5. Build fails with "out of memory"
Solution:
- Use
cargo build --release(release builds use less memory) - Increase swap space
- Build on a machine with more RAM
6. Cross-compilation fails
Solution:
- Ensure all cross-compilation toolchains are installed
- Check
.cargo/config.tomlfor target-specific settings - Some crates may not support all targets
Getting Help
- Check Rust Installation Guide
- Review Cargo Book
- Check crate-specific documentation for dependencies
- Open an issue on GitHub with:
- OS and version
- Rust version (
rustc --version) - Full error message
- Build command used
Build Configuration
Environment Variables
-
RUSTFLAGS: Additional flags for rustcexport RUSTFLAGS="-C target-cpu=native" # Optimize for current CPU -
CARGO_TARGET_DIR: Custom target directoryexport CARGO_TARGET_DIR=/custom/path
Cargo Configuration
Create .cargo/config.toml for project-specific settings:
[build]
# Use specific linker
target = "x86_64-unknown-linux-gnu"
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
Performance Tips
- Use Release Builds: Always use
--releasefor production - Enable LTO: Add to
Cargo.toml:[profile.release] lto = true - Optimize for Size: Add to
Cargo.toml:[profile.release] opt-level = "z" # Optimize for size - Parallel Compilation: Cargo uses all CPU cores by default
Next Steps
After building:
- Run tests:
cargo test - Check code quality:
cargo clippy - Format code:
cargo fmt - Review README.md for usage instructions