Compiling Wesnoth on Windows, old guides
For Visual Studio, the current guide can be found under CompilingWesnothOnWindows.
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 a walktrough, 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.
Visual Studio: Crab's method
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 the command-line executables for version control are 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)
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
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.
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