This is a short guide on how to set up a compiling environment on Windows, and using it to compile Naev.Refer to an older commit of this page for info about older workflows to be retired after Naev 0.8.0 (GNU Autotools builds, 32-bit builds).Note: The GNU Autotools build process can also support a cross-compile destined for Windows. Simply pass--host=x86_64-w64-mingw32 to./configure and proceed from there.
ucrt64.exe in your MSYS2 installation directory.To build, install the following:
pacman -S git tar mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-dlfcn mingw-w64-ucrt-x86_64-freetype mingw-w64-ucrt-x86_64-glpk mingw-w64-ucrt-x86_64-libvorbis\mingw-w64-ucrt-x86_64-libwebp mingw-w64-ucrt-x86_64-enet mingw-w64-ucrt-x86_64-libxml2 mingw-w64-ucrt-x86_64-luajit mingw-w64-ucrt-x86_64-mesa mingw-w64-ucrt-x86_64-physfs\mingw-w64-ucrt-x86_64-meson mingw-w64-ucrt-x86_64-libunibreak mingw-w64-ucrt-x86_64-libbacktrace mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-nsis mingw-w64-ucrt-x86_64-openal mingw-w64-ucrt-x86_64-glpk\mingw-w64-ucrt-x86_64-pkg-config mingw-w64-ucrt-x86_64-SDL2 mingw-w64-ucrt-x86_64-SDL2_image mingw-w64-ucrt-x86_64-suitesparse mingw-w64-ucrt-x86_64-python-yaml mingw-w64-ucrt-x86_64-ca-certificates mingw-w64-ucrt-x86_64-cmarkWhen asked to proceed with the installation, press y and hit enter.
Naev is gaining support for cross-compilation.The setup will depend on your distribution.For example, on Arch Linux, it's smart to use a system mingw-w64-ucrt-suitesparse package, criticalnot to use a system mingw-w64-luajit package (as of 2020-11-09 they're all broken), expedient to use wine-x64 instead of a complete Wine installation, and reasonable to use a helper likeyay to handle installing from the AUR.Thus, the setup could look like
pacman -S git meson lib32-gcc-libs nsis python-pipyay -S mingw-w64-gcc mingw-w64-pkg-config wine-x64 mingw-w64-openblas-lapack mingw-w64-metis# Manually build mingw-w64-gmp from AUR, after correcting the dependency on wine.yay -S mingw-w64-dlfcn mingw-w64-freetype2-bootstrap mingw-w64-gettext mingw-w64-glpk mingw-w64-libpng mingw-w64-libwebp mingw-w64-libxml2 mingw-w64-openal mingw-w64-sdl2_mixer mingw-w64-suitesparseYou will also need across file for the Meson build.This setup could look like
curl -O --output-dir ~/.local/share/meson/cross/ https://raw.githubusercontent.com/mesonbuild/meson/master/cross/linux-mingw-w64-64bit.txt$EDITOR ~/.local/share/meson/cross/linux-mingw-w64-64bit.txt(and update it to match the installed paths, e.g. "sys_root = '/'".)
Begin by starting either environment via the start menu, or by runningucrt64.exe in your MSYS2 installation directory. (On Linux, simply open a terminal.)
Clone the git repo. You can do this by entering:
git clone https://codeberg.org/naev/naev.git <source dir>cd <source dir>git submodule initgit submodule updategit config submodule.recursetrueWhere <source dir> is the name of the subdirectory to clone into (e.g., "naev").
If you're building on Windows, you should now run
meson setup <build dir> . --prefix=<full path to build dir>/windows --bindir=. -Dndata_path=.where <build dir> is the folder you'd like the build output to go. For example./build-output
<build dir> must be different than the <source dir>
If cross-compiling on Linux, you'll need an extra argument:
meson setup <build dir> . --prefix=<full path to build dir>/windows --bindir=. -Dndata_path=. --cross-file linux-mingw-w64-64bit.txtYou can choose any location for the build directory -- most usefully, outside the source tree, for example "../build-naev".Note: You should only need to do this once. After the first setup, you can update these settings using themeson configure command from the<build dir>.
When ready, justcd into the<build dir> created on step 2, and run
meson compileIf everything went without any errors, you should have a naev.exe in the current directory! However, it probably won't be able to find the DLL files it needs to start.
On Windows, themeson install command can package everything (including the required DLL files) into an NSIS installer or tar.xz archive.
First we will want to reconfigure meson to build us an NSIS installer:
From the build directory run:
meson configure -Dinstaller=trueIf you'd like a tar.xz archive run:
meson configure -Drelease=trueYou can mix and match those two options if you'd like both to be generated.
Then run:
meson installCheck the dist folder in your build directory for the tar.xz archive, or the NSIS installer.
Running this installer is the easiest way get the compiled game to work without complaining about missing DLL files.
You can launch Naev without installing by running the following command from<build dir>
meson devenv python ./naev.pyLore is being removed from the Wiki and moved intodocs/manual/lore/.
Deleting the wiki page "Compiling on Windows" cannot be undone. Continue?