From The Battle for Wesnoth Wiki

[edit]Compiling Wesnoth


Compiling Wesnoth on Windows

For instructions using Microsoft Visual Studio, see the last section. For methods based on other tool chains, please see the following:


While not currently documented on the wiki, there is an alternate method for compiling Wesnoth on Windows using CodeBlocks.

This uses the tdm-gcc compiler, and includes a link to the necessary dependencies.


Also, currently documented on the forums rather than the wiki, there is an alternate method (based on LoonyCyborg's official Windows build) which uses scons, and is reported to compile faster than code::blocks. Pentarctagon's instructions

Other tool chains / cross compiling

Note: This info is very out of date

Other toolchains than Visual Studio and tdm-gcc (GCC, MinGW, Dev-C++, ...) are treated on a separate page.

Visual Studio

Definition: wesnoth_root is the folder that contains the checkout of the trunk. The folder should contain folders like: data, doc, icons, packaging, projectfiles; and files like: COPYING, CMakeLists.txt, README.

VC14 is MSVC 2015 and VC15 is MSVC 2017. VCx denotes you should insert your specific version.

  1. Download the archive containing all required includes and libraries:
  2. Extract it into the parent directory of wesnoth_root and rename it from external-VCx to external. It should contain three subdirectories: dll, include, and lib.
  3. Add the external\dll directory to your PATH variable.
    If you don't know how to use the PATH variable, go here: , at the bottom of the page are the instructions + some screenshots to help you. This will be used to be able to start Wesnoth directly from the explorer.
  4. Copy wesnoth_root\projectfiles\VC14 to a new directory wesnoth_root\projectfiles\VCx (that doesn't apply if you're using Visual Studio 2015, of course). Go there and open wesnoth.sln to let Visual Studio automatically update the project.
  5. If you want to play the resulting wesnoth.exe, the default configuration (Debug) is unbearably slow. To correct this, switch from Debug to Release via the drop-down menu which you'll find in the toolbar at the top of the Visual Studio window.
  6. Build the solution by right clicking the 'Solution 'wesnoth' (6 projects)' item in the Solution explorer and selecting 'Build Solution'.
  7. To run the game, just Press F5 (debug) or CTRL+F5. Alternatively, you can run the new wesnoth.exe.

Updating VCx from VC14

Changes in the VC project files can be merged without needing to rebuild Wesnoth. Just delete any loose files in VCx (except wesnoth.ncb, wesnoth.suo, wesnoth.sdf, wesnoth.VC.db) and replace them by the contents of VC14.

Generating dependencies for other versions

Note: If there is no compatible external archive for your VC version, you can generate the necessary version specific files yourself:

  1. download and unpack the source of the libraries zlib, libbzip2, and boost
  2. in the 'Developer Command Prompt' that is installed with Visual Studio, go to the boost directory and type (with the correct paths of the other two libraries):

.\b2 -sZLIB_SOURCE=G:\zlib-1.2.8 -sBZIP2_SOURCE=G:\bzip2-1.0.6

To massively reduce compilation time, add
-jN --with-date_time --with-filesystem --with-iostreams --with-locale --with-program_options --with-random --with-regex --with-system --with-test --with-thread
to the b2 command, with N being the number of cores in your CPU (e.g. -j4 for a quad core).
Replace the files in 'external/lib' with those from 'boost_.../stage/lib' and those in 'external/include/boost' with 'boost_.../boost'.

See Also

This page was last edited on 18 March 2018, at 10:19.