Building for Windows
December 3, 2023 ยท View on GitHub
This is the main build procedure for Windows version.
Note that this build mode requires GCC for Windows (MinGW), since MSVC compiler cannot be used with Go.
For cross-compilation from Linux to Windows (including WSL), see this page.
Installing Go compiler
See official docs.
To check that installation was successful, open cmd.exe and write go version.
It should print the version you installed.
Installing MSYS2, MinGW and other dependencies
- Install MSYS2.
- Run MSYS2 shell (search for
MSYS2 MSYSshortcut in Start menu). - Update default packages:
pacman -Syu. Confirm by typingY, when asked. If it asks for a restart and closes after the update, reopen the shell and update again. - Install dependencies:
pacman -S --needed git base-devel mingw-w64-i686-toolchain mingw-w64-i686-SDL2 mingw-w64-i686-openal(confirm by selection with Enter, then confirms installation with typingY). - Add Go compiler to MSYS2
PATHvariable:echo 'export PATH="/c/Program Files/Go/bin/:$PATH"' >> ~/.bashrc - Restart the shell again to apply
PATHchanges. - Check if Go compiler is detected:
go version.
Downloading the project
As a ZIP file
Download the latest source and extract it to some directory.
We will assume the project is unpacked to C:\Dev\opennox for this guide. Prefer path without spaces and non-English characters.
Using Git
- Install Git for Windows. Click "next" for all the steps - defaults are good already.
- Install TortoiseGit. When asked for a name and email, either fill it in, or skip by checking the box. It's only used when sending changes to the project.
- Create a directory for projects, let's say
C:\Dev\. - Right click on empty space in the new folder, select "Git Clone...".
- Paste the project URL:
https://github.com/noxworld-dev/opennox.git. - Check the "Branch" box, write
devto the field. - Click OK, wait for the project to download.
Building
Run MINGW32 shell (search for MSYS2 MINGW32 or MSYS2 MinGW x86 shortcut in Start menu).
NOTE: This is a different shell shortcut, not the one used for updates!
Assuming OpenNox was downloaded into C:\Dev\opennox:
cd /c/Dev/opennox/src
go run ./internal/noxbuild
You should see that the project dependencies are being downloaded and compiled.
During this process you way see a lot of scary warnings. Don't panic! This is normal.
Build may take a while, especially when building for the first time. Be patient.
If you hit issues, see troubleshooting section below.
Once finished, it should produce opennox.exe, opennox-hd.exe and opennox-server.exe binaries in C:\Dev\opennox\src.
Troubleshooting
gcc not found
Make sure you start the MSYS2 MINGW32 shell, not MSYS2 MSYS (or any other).
Cannot find OpenAL32
- Go to MSYS2 installation directory (
C:\msys64by default). - Open folder
mingw32\lib. - Find files
libopenal.aandlibopenal.dll.a. - Make a copy of both files with a new names:
libopenal32.aandlibopenal32.dll.a. - Rebuild the project.
Following builds are still slow
First, noxbuild builds all binaries: legacy, HD and server.
You can set it to build only one of them. For example, for HD version only:
go run ./internal/noxbuild client-hd
For legacy only:
go run ./internal/noxbuild client
This should make it much faster, but it may still take a few minutes, unfortunately.
Running
You also need a few DLLs for these binaries to work.
- Create new folder for OpenNox, let's say
C:\Games\OpenNox. - Copy following binaries from
C:\Dev\opennox\src:opennox.exeopennox-hd.exeopennox-server.exe
- Copy following DLLs from
C:\msys64\mingw32\bin:libgcc_s_dw2-1.dlllibopenal-1.dlllibstdc++-6.dlllibwinpthread-1.dllSDL2.dll
- Run
opennox.exeoropennox-hd.exe.- If it complains about more DDLs - copy them from MSYS.
- If it says that Nox directory not found - it works! Check this guide to set Nox game path.