Skip to content

Compiling and or running

Cldfire edited this page Oct 20, 2016 · 10 revisions

Table of contents

Prerequisites

Compiling steven-rust requires a working rust nightly installation, openssl and sdl2. Instructions for setting up openssl and sdl2 are platform-specific and will be covered as such outside of this section.

An easy way to manage multiple Rust toolchains is rustup. Installation instructions for rustup can be found on its website.

Once you've set up rustup, grab rust nightly by running

rustup install nightly

Now we need to make sure that steven-rust is compiled with nightly. To do this without making nightly the default across the entire system, run the following command in the steven-rust directory:

rustup override set nightly

Compiling on Linux

Installing dependencies

Install openssl and sdl2 (with headers) via your distro's package manager. (Packages with headers generally end with -dev)

Compiling

Compile and run:

cargo run --release

Just compile:

cargo build --release

Compiling on OS X

Installing dependencies

Installing them is easiest with homebrew.

To install openssl and sdl2 issue these commands:

brew install sdl2
brew install openssl

Older versions of OS X come with an older version of openssl while El Capitan and newer do not come with it at all. Compiling steven-rust with older OS X versions would most likely work without installing the openssl library (and using the OPENSSL_ environment variables), but I would recommend installing it anyway.

TODO: Instructions without homebrew

Compiling

To compile steven-rust you can use this simple bash script to set the environment variables so the compiler can find the required libraries.

#!/bin/bash
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include
export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib
cargo "$@"

Compile and run:

./scriptname.sh run --release

Just compile:

./scriptname.sh build --release

Alternatively you can skip the script and add the variables directly to the command:

LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include OPENSSL_LIB_DIR=`brew --prefix openssl`/lib cargo build --release

Note: If you're not using homebrew you probably don't need to set the environment variables.

Compiling on Windows

Note: Make sure that you have the rust nightly GNU ABI toolchain installed with rustup rather than the MSVC ABI. You can check this by running rustup show and ensure that you grab the GNU ABI toolchain with rustup install nightly-gnu

Installing dependencies

Follow the instructions at https://msys2.github.io to install msys and mingw. After that, run the following command from msys:

pacman -S git tar mingw-w64-x86_64-openssl mingw-w64-x86_64-SDL2 mingw-w64-x86_64-gcc

Compiling

Compile and run:

cargo run --release

Just compile:

cargo build --release