CompilingWesnothOnWindows

From Wesnoth


Contents

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:

Code::Blocks

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.

scons

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.

VC9 is MSVC 2008, VC10 is MSVC 2010, and MSVC 2013 is VC12. 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.

Due to some differences, Visual Studio 2008 is handled in a separate section.

Visual Studio 2010 and later

  1. Download the archive containing all required includes and libraries:
  2. Extract it somewhere. You can put it for example in C:\external\. Add the following in the PATH variable: C:\external\dll. 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.
  3. Copy wesnoth_root\projectfiles\VC9 to a new directory wesnoth_root\projectfiles\VCx. Go there and open wesnoth.sln to let Visual Studio automatically update the project.
  4. In the solution explorer, select all subprojects but WindowsTimeout (liblua, schema_generator, wesnoth, wesnothd, wesnothlib) at once by holding down the CTRL key while selecting.
    • Choose Properties in the right click menu, then Configuration Properties->'VC++ Directories' in the left pane.
    • At the top, set 'Configuration' to 'All Configurations'.
    • Add the path for external\include to 'Include Directories' and for external\lib to 'Library Directories':
      Copy the paths in front of the current entries and separate them by a semicolon. This could result in e.g.
      C:\external\include;$(IncludePath) and C:\external\lib;$(LibraryPath).
      Do not insert any quotes in or around these paths.
    • Confirm with 'Ok'.
  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 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.

Last check for compiling this way at commit c8699e2f05 (Wesnoth 1.13+dev) - May 29 2014.

Visual Studio 2008

  1. Download the archive containing all required includes and libraries:
    http://sourceforge.net/projects/wesnoth/files/unofficial/Windows%20Compile%20Stuff/externalVC9.zip/download
    Note: The linker will complain about a missing bzip2 library. Until someone updates the VC9 archive, you will need to build libboost_bzip2 yourself (see below). Alternatively, there is an accordingly updated package by a GSoC applicant:
    https://dl.dropbox.com/u/20447449/externalVC9.zip
  2. Extract it somewhere. You can put it for example in wesnoth_root/projectfiles/VC9/external. Add the following in the PATH variable: wesnoth_root/projectfiles/VC9/external/dll, where replacing the wesnoth_root with the real path. 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.
  3. Open Visual Studio by opening wesnoth_root/projectfiles/VC9/wesnoth.sln.
  4. Register the external folder as a dependency:
    • Go to the 'Tools' Menu -> Options. In the left pane, expand 'Projects and Solutions' -> 'VC++ Directories'.
    • There are 2 dropdown boxes. Select 'Include Files' from the second.
    • Now press the 2nd button beneath it, 'new line'.
    • When clicking on the empty line, in the most-right, there will be a '...' button.
    • Click it and browse for the wesnoth_root/projectfiles/VC9/external/include folder. Press Ok
    • Repeat last 3 points for the 'Library files' in the second dropdown, but put it to point to: wesnoth_root/projectfiles/VC9/external/lib
    • Finally click OK.
  5. Build the solution by right clicking on 'Solution 'wesnoth' (6 projects)' item in the Solution explorer, and selecting 'Build Solution'.
  6. To run the game, just Press F5 (debug) or CTRL+F5. Alternatively, you can run the new wesnoth.exe.

Generating dependencies for other versions

Note: If there is no compatible external archive for your VC version, you can update an old one yourself:

  1. download and unpack the source of the libraries zlib, libbzip2, boost (version 1.56 or later, version 1.55 is bugged)
  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):
    bootstrap
    .\b2 -sNO_ZLIB=0 -sZLIB_SOURCE=G:\zlib-1.2.8 -sNO_BZIP2=0 -sBZIP2_SOURCE=G:\bzip2-1.0.6
  3. replace the outdated 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 modified on 4 July 2014, at 20:24.