Difference between revisions of "CompilingWesnothOnWindows"

From The Battle for Wesnoth Wiki
m (update link to Crab's method)
(Compiling Wesnoth on Windows)
Line 3: Line 3:
  
 
== Compiling Wesnoth on Windows ==
 
== Compiling Wesnoth on Windows ==
 +
Note: While not currently documented on the wiki, there is an alternate method for compiling Wesnoth on Windows using [https://github.com/wesnoth/wesnoth/tree/master/projectfiles/CodeBlocks CodeBlocks].
 +
 +
 
Other toolchains than Visual Studio (GCC, MinGW, Dev-C++, ...) are treated on a [[CompilingWesnothOnWindowsOld|separate page]].
 
Other toolchains than Visual Studio (GCC, MinGW, Dev-C++, ...) are treated on a [[CompilingWesnothOnWindowsOld|separate page]].
  

Revision as of 14:04, 31 March 2014

[edit]Compiling Wesnoth

Platforms
Tools


Compiling Wesnoth on Windows

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


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


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 G:\external\. Add the following in the PATH variable: G:\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. For the projects that are part of the solution (liblua, wesnoth, wesnothd, wesnothlib), repeat:
    1. In the solution explorer, right click the project -> Properties, and in the left pane select Configuration Properties->'VC++ Directories'.
    2. At the top, set 'Configuration' to 'All Configurations'.
    3. 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.
      'G:\external\include;$(IncludePath)' and 'G:\external\lib;$(LibraryPath)'.
    4. Confirm with 'Ok'.
  5. If you want to play the resulting wesnoth.exe, the default configuration (Debug) is unbearably slow. To correct this, right click on the 'wesnoth' solution, go to Properties -> Configuration Properties and set all 'Configuration' entries to ReleaseDEBUG.
  6. Build the solution, by right clicking the 'Solution 'wesnoth' (4 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 983f14663d (Wesnoth 1.13+dev) - 21 March 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
  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' (4 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.

Version specific information

Note: For MSVC 2008 and 2010, the linker will complain about a missing bzip2 library. Until someone updates above archives you will need to build them yourself.

The missing lib files can also be downloaded from http://www.boostpro.com/download/ The vc9 archive above has 1.46.1 so if you downloaded that choose 1.46.1, download everything bzip2-related, and copy the files MSVC asks for into the folder with the other libs. There are also accordingly updated packages by a GSoC applicant:


Note: If Visual Studio 2013 complains about missing files for any C++ project whatsoever, the standard values for 'VC++ Directories' are incorrect. Installing Windows SDK 8.1 can fix these.


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