Compiling on Windows
Dependencies
BZFlag uses Visual C++ 2017 (VC15), which is part of Visual Studio 2017. The Community edition may be downloaded for free, though does require a (free) Microsoft account for continued use. Run the Visual Studio 2017 installer and choose to install "Desktop Development with C++". Additionally, since new versions of the Windows SDK are constantly coming out, you may need to update the bzflag-dependencies build script and upgrade our project files to target the current version.
The commands below assume the use of the command line git client from Git for Windows with the Command Prompt.
Using Git Bash will handle directory paths slightly different (affecting the mkdir
and cd
commands under "Compiling
the dependencies") and using a Git GUI program will also deviate from our instructions.
We provide a repository of third-party dependencies for building on Windows. We provide a script to build these. Additionally, if your intent is to build an installer, it is necessary to install NSIS 3. The installer will be built only from our fullbuild solution in Release mode.
Compiling the dependencies
Note: Some of our dependencies do not support spaces in the path. It is suggested to work out of a path such as
C:\code\
to avoid that kind of problem.
For BZFlag 2.4:
cd \code
git clone --branch 2.4 https://github.com/BZFlag-Dev/bzflag-dependencies.git
For BZFlag master (2.5):
cd \code
git clone --branch master https://github.com/BZFlag-Dev/bzflag-dependencies.git
Once the repository is cloned, navigate to the directory and run the buildVC2017.bat file. This will take a bit to run but should result in successful builds.
Using the dependencies
Once you have compiled the dependencies, you need to ensure that BZFlag can find them.
For BZFlag 2.4:
An environment variable called BZ_DEPS must point to the directory containing the various output directories. Navigate
to the Environment Variables control panel. Create a new user environment variable called BZ_DEPS and point it to the
directory that contains the directory that contains the licenses, output-release-x86, and output-debug-x86 directories.
In our example, this would be C:\code\bzflag-dependencies\
. Once the environment variable has been created, log off
and back on or reboot for the change to take effect.
For BZFlag master (2.5):
Create a "dependencies" directory alongside the src and include directories in the source root of BZFlag. Copy the output-* and licenses directories to the dependencies directory in the BZFlag source root.
Obtaining the code
For BZFlag 2.4:
Either download and extract the specific release source .zip from our downloads archive or use Git to download the current 2.4 branch.
For BZFlag master (2.5):
Building the code
The MSVC directory contains three Visual Studio solution files:
- fullbuild.sln - Includes the game client, server, server plugins, installer, and bzadmin
- bzflag.sln - Includes just the game client
- bzfs.sln - Includes just the server and plugins
Open the solution file of your choice. Navigate to the Build menu and choose Build Solution. The projects in your chosen solution should build and will produce output in a directory such as bin_Debug_Win32.
Debugging
If you need to debug both the client and server at the same time on the same computer, you can run two instances of Visual Studio with one using bzflag.sln and the other using bzfs.sln. Both of these will also have the correct startup project selected by default. If you use the fullbuild.sln solution, you will right click on either bzflag, bzadmin, or bzfs in the Solution Explorer and choose "Set as StartUp Project".
Ensure that the software was compiled in Debug mode and not in Release mode. After that, debugger settings must be configured. Right click on the project in the Solution Explorer and click on Properties. Select the Debugging item on the left. Click into the value for the command, then click the down arrow on the right and select <Browse...>. Navigate to the bin_Debug_Win32 directory at the root of the BZFlag source and double click on the corresponding executable for your project (such as bzflag.exe for the bzflag project). Set the Working Directory to the bin_Debug_Win32 directory.
Optionally, you may also specify Command Arguments. For the bzflag project, you may for instance wish to run the client
in a window instead of fullscreen, which can be accomplished with the -window 800x600
arguments. That would run the
game in a window that is 800 pixels wide and 600 pixels high.
Once you have your values set, click OK to save the settings. You may then go to the Debug menu and choose Start Debugging. We won't go into how debugging works as there are plenty of tutorials and documentation online for that, including a good overview from the Visual C++ Team Blog.
More information
For more information, review the README.Windows and DEVINFO files from the source.
This content is maintained on GitHub. We welcome any feedback and improvements!