Compiling Wesnoth on Windows
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.
This method is based on Crab_'s method (described below). But, instead of using cmake, we will use the original/manually updated project file. That file is in: wesnoth_root/projectfiles/VC9/wesnoth.sln or in wesnoth_root/projectfiles/VC10/wesnoth.sln. It depends on what Visual Studio are you using. MSVC 2008 is VC9 and MSVC 2010 is VC10. Based on your current IDE just the specific path. If it's written VCx, that means that it doesn't matter/depends on what version you're gonna use.
Download the archive containing all required includes and libraries:
Note: The linker will complain about a missing bzip2 library. Until someone updates the above archives you will need to build them yourself This archive contains essentially the same as Crab_'s, but insted it's organized (like in "linux") to be better used in Visual Studio
- Extract it somewhere. You can put it for example in: wesnoth_root/projectfiles/VCx/external. Add the following in the PATH variable: wesnoth_root/projectfiles/VCx/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.
- For Visual Studio 2008, start the Visual studio by running wesnoth_root/projectfiles/VC9/wesnoth.sln.
- In visual studio, 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.
- For Visual Studio 2010, start the Visual studio by running wesnoth_root/projectfiles/VC9/wesnoth.sln:
- Follow the steps suggested by the VS Conversion Wizard to upgrade your project files
- In visual studio, right click the wesnoth project -> Properties, and in the left pane select Configuration Properties->'VC++ Directories'.
- You'll need to edit the 'Include' and 'Library' directories. To edit one, click on the textbox in the right of the label, and a little arrow will be shown. Click on that and then, 'Edit...'
- In the new windows, there is the left-most upper button, like a new directory (New line). Click on that, and a new empty line will appear.
- When clicking on the empty line, in the most-right, there will be a '...' button.
- Click it and browse for the wesnoth_root/projectfiles/VC10/external/include folder. Press Ok
- Repeat last 3 points for the 'Library directories', but put it to point to: wesnoth_root/projectfiles/VC10/external/lib
- Repeat all this steps (starting at 1) for the wesnothd and wesnothlib projects as well.
- Finally click OK.
- Build the solution, by right clicking the 'Solution 'wesnoth' (4 projects)' item in the Solution explorer, and selecting 'Build Solution'.
- To run the game, just Press F5 (debug) or CTRL+F5. Alternatively, to run it from other locations/explorer
Latest check for compiling this way, it's trunk r49973 - 21 July 2011.
See guide in in this forum topic. Since it tends to change rather often with new mingw relases/wesnoth dependencies and I tend to forget to update the wiki I suggest visiting abovementioned topic for waltrough, some insight, shortcuts and other feedback.
On 10-04-2008 there are two guides there- setting up gcc 3.4.5 toolchain in first post, and setting up gcc 4.2.1 in the second one. I personaly suggest the latter since that enviroment works faster and produces faster code and I do not maintain 3.4.5 version anymore (though it doesn't mean it's not maintained at all, there still are devs using it and they update project files once every while)
Post Scriptum : It may also happen that I forget to update wesnoth.dev after source files are added/removed. In that case instead of wesnoth.exe you'll get awful lot of errors in this format <name1>::<name2>::<function>. Try to find a file in the /src directory (and subfolders) thats not included in the project and add it, or you might wait a bit. I recompile wesnoth quite often and will post patched wesnoth.dev on the forum thread.
On 2005-03-27, baro wrote:
Just to let you know, it is no problem to compile wesnoth for windows using free tools. I used "devcpp" and "msys", downloaded all needed libraries via the devcpp package downloader, compiled freetype2 and then wesnoth with msys.. using linux like ./configure and make
The source code includes a project file for VC++ 6 which is kept up to date since Dave uses that environment. Yes, he is aware that it is very old.
Azlan tried to compile using mingw32 using the Dev-C++ IDE, but was having problems linking.
Wintifax reported having built using Visual Studio 7.1 (.Net 2003) and posted instructions.
Enzo successfully built using mingw32 and included instructions and a link to the downloadable installer. Some of the postings in this thread discuss issues with this build, but it does seem reasonable.
SL also reported building successfully, giving quite a lot of detail.
Wesnoth 1.9 (since r41888) and branches/1.8 (since r42011) can be compiled using cmake+msvc9
note: "%PATH%" in this guide refers to a environment variable of windows; if you type e.g. "cmake" in a command window (start>run>enter "cmd">ok) and you get a message about that the command hasn't been found it means that something with your environment variables is wrong. It is, however, also possible to enter the full path to cmake's executable instead of only "cmake" (which doesn't require putting cmake into %PATH%).
- make sure that svn command-line executable is in your %PATH%
- for wesnoth 1.8: download ftp://ftp.terraninfo.net/wesnoth/msvc9/external.zip (55mb download) and unpack it into wesnoth's directory - so, there'll be an external folder in there.
- for wesnoth 1.9: download ftp://ftp.terraninfo.net/wesnoth/msvc9/external_19.zip (59mb download) and unpack it into wesnoth's directory - so, there'll be an external folder in there.
- install cmake http://www.cmake.org/cmake/resources/software.html and put it into %PATH% (that can be done by the installer)
- to allow the game to run, put full path to external/dll into %PATH% note: This step is only required for executing (from within MSVC), not until the built is finished. Alternatively, the required dlls can be copied into the wesnoth folder (parent directory, into which you downloaded or unpacked wesnoth's source and where the external/ folder is).
- run external/msvc9-cmake.bat (from within external directory) by double-clicking the file. You can run the .bat file also by navigating into the external/ folder within a command window (command "cd" for changing the directory) and typing "wesnoth-msvc9.bat". This will show you any error messages if something went wrong instead of insta-closing the window.
- open generated project file in msvc9 (file Project.sln)
- remove 'ana' from a list of projects that are compiled by default (ana-static should be compiled, ana should not be compiled) To do that, right-click project wesnoth>configuration properties>configuration manager>uncheck project "ana".
- compile. the project should pick up changes in cmake files automatically. Also, you can re-run the .bat file to regenerate it.
last one checked and known to work: trunk r45254m (Sat, Sep 4th, 2010)
[Xan's guide to Compiling the Battle for Wesnoth on Windows]
1. Acquire tools
a. Dev-C++ from http://www.bloodshed.net/devcpp.html
b. MSYS from http://www.mingw.org/
d. libintl from Dev-C++ package
f. SDL from Dev-C++ package
g. SDL_image from Dev-C++ package
i. SDL_net from Dev-C++ package
h. SDL_mixer from Dev-C++ package
j. bzip2 from Dev-C++ package
k. zlib from Dev-C++ package
l. libcurl from Dev-C++ package
All the Dev-C++ packages can be downloaded from the Dev-C++ IDE.
2. Setting up libraries
a. Install MSYS. When it asks if you have mingw installed, give it the path to your Dev-C++ directory.
b. Copy the Jam executable to the MSYS /bin directory.
c. Go to the control panel, and open 'System'. Click on the 'Advanced' tab. Click the 'Environment Variables' button. Make a new user variable called 'JAM_TOOLSET' with a value of 'MINGW', and make a new user variable called 'MINGW' where the value is the absolute path to your Dev-C++ install.
d. Run MSYS, go to the freetype2 directory, and type 'jam'. The freetype library should automatically compile. Rename the 'freetype.a' in the 'objs' directory to 'libfreetype.a', and copy it to the Dev-C++ 'lib' directory.
3. Making a jamfile for Wesnoth
Create a file called 'jamfile' in wesnoth/src and copy the lines below to it. Then replace all the $(Path)s, including the '$' with the absolute path to that directory.
# START Jamfile
HDRS = "$(WesnothPath)/src" "$(DevC++Path)/include/SDL" "$(WesnothPath)/src/sdl_ttf" "$(FreeType2Path)/include" ;
ALLLINKLIBS += -lmingw32 ;
LINK = g++ ; CC = g++ ; C++ = g++ ;
ALLLINKLIBS += -lSDLmain -lSDL -lSDL_image -lSDL_net -lSDL_mixer -lbz2 -lz -lcurl -lwsock32 -lws2_32 -lwinmm -lfreetype -lintl -mwindows ;
LINKLIBS on Wesnoth$(SUFEXE) = $(ALLLINKLIBS) ;
Main Wesnoth : about.cpp actions.cpp ai.cpp ai_dfool.cpp ai_attack.cpp ai_move.cpp ai_python.cpp animated.cpp astarnode.cpp builder.cpp cavegen.cpp checksum.cpp clipboard.cpp color_range.cpp config.cpp config_adapter.cpp cursor.cpp dialogs.cpp display.cpp events.cpp filechooser.cpp filesystem.cpp font.cpp game.cpp game_config.cpp game_events.cpp gamestatus.cpp gettext.cpp halo.cpp help.cpp hotkeys.cpp image.cpp intro.cpp key.cpp language.cpp leader_list.cpp log.cpp map.cpp map_create.cpp map_label.cpp mapgen.cpp mapgen_dialog.cpp marked-up_text.cpp menu_events.cpp minimap.cpp mouse.cpp mouse_events.cpp multiplayer.cpp multiplayer_ui.cpp multiplayer_wait.cpp multiplayer_connect.cpp multiplayer_create.cpp multiplayer_lobby.cpp network.cpp network_worker.cpp pathfind.cpp pathutils.cpp playcampaign.cpp playlevel.cpp playturn.cpp preferences.cpp preferences_display.cpp publish_campaign.cpp race.cpp random.cpp replay.cpp replay_controller.cpp reports.cpp sdl_utils.cpp show_dialog.cpp sound.cpp statistics.cpp team.cpp terrain.cpp theme.cpp thread.cpp titlescreen.cpp tooltips.cpp tstring.cpp unit.cpp unit_animation.cpp unit_display.cpp unit_types.cpp upload_log.cpp util.cpp variable.cpp video.cpp wassert.cpp serialization/binary_or_text.cpp serialization/binary_wml.cpp serialization/preprocessor.cpp serialization/parser.cpp serialization/string_utils.cpp serialization/tokenizer.cpp widgets/button.cpp widgets/combo.cpp widgets/file_chooser.cpp widgets/image_button.cpp widgets/label.cpp widgets/menu.cpp widgets/progressbar.cpp widgets/scrollarea.cpp widgets/scrollbar.cpp widgets/scrollpane.cpp widgets/slider.cpp widgets/textbox.cpp widgets/widget.cpp sdl_ttf/SDL_ttf.c zipios++/xcoll.cpp ;
# END Jamfile
Note that the above list of source files may need to be edited depending on the version of Wesnoth you are compiling.
4. Compiling Wesnoth
a. Run MSYS and go to the wesnoth/src directory.
b. Type 'jam'
c. Wesnoth should now compile!
Cross compiling for Windows
Forcemstr has cross compiled for Windows using the free mingw32 tools, running under Linux.
Or see here for another attempt: http://www.wesnoth.org/wiki/CompilingWesnoth/CrossCompiling