You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The @rust-embedded project provides a handy tool called cross that uses docker to cross-compile any cargo project to one of their many supported platforms. This tool makes it easy to cross-compile raylib-rs for binary distribution (in cases where you are producing a pre-compiled game for example).
Anything to Windows
Cross-compiling from other platforms to Windows is the simplest. Just build your project with this command instead of the usual cargo build:
It should be noted that the resulting exe will likely not run under wine due to an issue with Raylib's audio handling.
Anything to Linux
Cross-compiling from any platform to Linux, or from Linux to Linux requires a little extra work since raylib-sys has some system dependencies not provided by cross. This following example assumes you are compiling for x86_64-unknown-linux-gnu, but it can be any Linux-y triple.
Firstly, a custom build container must be defined. The following Dockerfile is the minimum setup for compiling raylib-sys:
FROM rustembedded/cross:x86_64-unknown-linux-gnu-0.2.1
RUN apt-get update -y
RUN apt-get install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev -y
With the image defined, build it locally with:
docker build -t raylib_rs_env .
This will produce a local docker image called raylib_rs_env which cross will use instead of the default Linux image(s). To tell cross to use this image, create a Cross.toml file beside your Cargo.toml, and add the following (remembering to change things to suit your setup):