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.
(Version 1.13.5 and later only) The Visual Studio project files were updated from VC9 to VC12, these instructions have to be adapted accordingly.
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.
VC9 is MSVC 2008, VC10 is MSVC 2010, VC12 is MSVC 2013, and VC14 is MSVC 2015. VCx denotes you should insert your specific version.
This method is based on Crab's method. But, instead of using cmake, we will use the original/manually updated project file wesnoth_root/projectfiles/VC9/wesnoth.sln.
- Download the archive containing all required includes and libraries:
- MSVC 2008: https://github.com/aquileia/external/archive/VC9.zip
- MSVC 2010: https://github.com/aquileia/external/archive/VC10.zip
- MSVC 2013: https://github.com/aquileia/external/archive/VC12.zip
- MSVC 2015: https://github.com/aquileia/external/archive/VC14.zip
- Git users can just clone the underlying repo and checkout the respective branch.
- 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.
- Add the external\dll directory to your PATH variable.
If you don't know how to use the PATH variable, go here: http://vlaurie.com/computers2/Articles/environment.htm , 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.
- Copy wesnoth_root\projectfiles\VC9 to a new directory wesnoth_root\projectfiles\VCx (that doesn't apply if you're using Visual Studio 2008, of course). Go there and open wesnoth.sln to let Visual Studio automatically update the project.
- 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.
- Build the solution by right clicking the 'Solution 'wesnoth' (6 projects)' item in the Solution explorer and selecting 'Build Solution'.
- To run the game, just Press F5 (debug) or CTRL+F5. Alternatively, you can run the new wesnoth.exe.
Last check for compiling this way at commit 6d64baa207 (Wesnoth 1.13+dev) - Jul 27 2015.
Updating VCx from VC9
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 VC9.
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:
- download and unpack the source of the libraries zlib, libbzip2, and boost
- 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-locale --with-regex --with-filesystem --with-system --with-program_options --with-random --with-thread --with-iostreams --with-date_time
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'.