|
|
(18 intermediate revisions by 5 users not shown) |
Line 1: |
Line 1: |
− | = Prerequisites =
| + | #REDIRECT [[How_to_build_VCMI_(Windows/Vcpkg)]] |
− | * Installed Heroes3 (can be bought for $10 at [http://www.gog.com/en/gamecard/heroes_of_might_and_magic_3_complete_edition/ gog.com])
| |
− | * Installed WoG or ERA add-on over H3 ([http://download.vcmi.eu/WoG/WoG_Install.7z WoG Installer]).
| |
− | * IDE: Microsoft Visual C++ 2012 Express for Desktop. It can be downloaded for free from [http://www.microsoft.com/visualstudio/eng/downloads#d-express-windows-desktop microsoft.com]. Higher editions of Visual Studio (Professional, Premium and Ultimate) are also supported. VCMI can be also built with GCC 4.5+, however since it's not covered in this tutorial, we strongly suggest using MSVC on Windows, unless you're an advanced developer (but then you wouldn't need this tutorial :]).
| |
− | * SVN Client: TortoiseSVN. Available (for free) at [http://tortoisesvn.net/downloads tortoisesvn.net].
| |
− | * Libraries pack: [http://download.vcmi.eu/msvc-pack.7z download.vcmi.eu]. It contains includes and pre-built binaries of several libraries VCMI uses. You DO NOT need to download them, they're in the pack. The libraries included are:
| |
− | ** [http://www.libsdl.org/ SDL]
| |
− | ** [http://www.libsdl.org/projects/SDL_image/ SDL_image]
| |
− | ** [http://www.libsdl.org/projects/SDL_mixer SDL_mixer]
| |
− | ** [http://www.libsdl.org/projects/SDL_ttf/ SDL_TTF]
| |
− | ** [http://www.zlib.net/ zlib]
| |
− | * Boost libraries in version 1.51 or newer. You can build them on your own using sources from [http://www.boost.org/users/download/ boost.org] (it's very simple) or download precompiled binaries with installer from [http://www.boostpro.com/download boostpro.com].
| |
− | | |
− | == For Visual Studio 2010 users ==
| |
− | Note: Visual Studio 2010 support is still present though deprecated (and expected to be dropped in Feb 2013). To use Visual Studio 2010 with project files from repository follow this tutorial with the following exceptions:
| |
− | * use VCMI_VS10.sln solution (not VCMI_VS11)
| |
− | * in the properties of all projects change Platform Toolset to Visual Studio 2010 (v100).
| |
− | * when building Boost replace msvc-11.0 with msvc-10.0
| |
− | | |
− | = Preparing place =
| |
− | == Initial directory structure and libraries pack ==
| |
− | Create a directory for VCMI development, eg. C:\VCMI. Extract there libraries pack. It contains initial directory structure.
| |
− | | |
− | == VCMI sources ==
| |
− | Libraries pack contains default subfolder for VCMI sources named trunk. Right click it and select SVN Checkout from context menu.
| |
− | | |
− | [[File:trunk-menu.png|250px]]
| |
− | | |
− | | |
− | In the dialog type (or paste :]) https://vcmi.svn.sourceforge.net/svnroot/vcmi/trunk/ as URL of repository.
| |
− | | |
− | [[File:Checkout.png|250px]]
| |
− | | |
− | | |
− | Hit OK and latest VCMI sources will be downloaded from the repository. Double click VCMI_VS11.sln file to open VCMI projects in Visual Studio.
| |
− | | |
− | == Boost libraries ==
| |
− | | |
− | === Building from sources ===
| |
− | Boost libraries sources are distributed as an archive file containing single folder named like "boost_1_53_0". Let's assume that you've extracted the archive into C:\C++ folder.
| |
− | | |
− | Instructions on how to build Boost are available in the [http://www.boost.org/doc/libs/release/more/getting_started/ libraries documentation]. As for 1.53.0 version it's as simple as typing in the '''Visual Studio Command Prompt''' (look for it in your Start menu) the following:
| |
− | <pre>cd "C:\C++\boost_1_53_0"
| |
− | bootstrap
| |
− | b2 address-model=32 --toolset=msvc-11.0 --stagedir=./stage32</pre>
| |
− | | |
− | If you want to build 64-bit version of VCMI issue also
| |
− | <pre>b2 address-model=64 --toolset=msvc-11.0 --stagedir=./stage64</pre>
| |
− | | |
− | When build is complete (it may take some time), there should exist folder C:\C++\boost_1_53_0\stage32\lib containing numerous *.lib files. It's your Boost '''library directory'''. Your Boost '''include directory''' will be C:\C++\boost_1_53_0.
| |
− | | |
− | === Obtaining precompiled binaries from Boostpro (only for VC10 users) ===
| |
− | At the moment (December 2012) Boostpro doesn't provide binaries for Visual Studio 2012.
| |
− | | |
− | If you use Visual Studio 2010 then you can use Boostpro Boost distribution. When installing make sure that following options are checked in the "Select Default Variants" screen:
| |
− | * Visual C++ 10.0
| |
− | * Multithreaded
| |
− | * Multithreaded debug
| |
− | | |
− | = Adjusting project files =
| |
− | == Adding Boost library folders ==
| |
− | All projects are aware of includes/ and libs/ directories in the main VCMI folder. Because libraries package uses them, the only remaining issue is giving IDE information where you have Boost library (the only library not included in the package).
| |
− | | |
− | | |
− | There are several alternative ways to do that:
| |
− | === Global ===
| |
− | By following these steps, you'll enable Boost for all your projects in Visual Studio. If you wish to use Boost in your other projects without repeating this setup, this scenario is recommended.
| |
− | | |
− | # Select "expert settings" mode (Tools -> Settings -> Expert Settings). This step may not be needed for Visual Studio editions other then Express.
| |
− | # Open Property Pages (View -> Property Pages).
| |
− | # In the property manager panel (that just showed up) expand any project and then expand any Win32 configuration within it (Debug or RD). It doesn't make any difference which project and configuration you'll pick, since they all share the one property sheet we're interested in.
| |
− | # Double click on Microsoft.Cpp.Win32.user (or r-click it -> Properties). Property window opens.
| |
− | # Select "VC++ Directories".
| |
− | # Click on "Include Directories" row.
| |
− | ## A small button on the right appears. Click it and click on <Edit...>.
| |
− | ## Click on "New Line" icon.
| |
− | ## Click on "..." batton on the right of textbox that appeared.
| |
− | ## Select your Boost '''include directory''' (eg. C:\C++\boost_1_47_0). Confirm with OK.
| |
− | ## Check if your folder path correrctly appeared on the list. Click OK to save changes and dismiss window.
| |
− | # Click on "Library Directories" row. Repeat the steps described for "Include directories", just this time select Boost '''library directory''' (eg. C:\C++\boost_1_47_0\stage\lib).
| |
− | # Close the property page with OK.
| |
− | | |
− | [[File:vc_dirs.png|250px]] [[File:include.png|250px]]
| |
− | | |
− | === For all VCMI projects ===
| |
− | Follow the instructions from previous section with one exception — in step 4. select VCMI_global property sheet.
| |
− | | |
− | === Individually per project ===
| |
− | Add Boost individually for each of the VCMI projects. This is not recommended, since it's most tiresome way.
| |
− | | |
− | Open solution explorer. Right click on the project and select "Properties". Follow steps 5 — 8 from "Global" section. Repeat for each project.
| |
− | | |
− | === Put along with other libs ===
| |
− | Project files are pre-configured to use includes/ and libs/ subfolders (that are meant to be next to the trunk folder) during lookup for headers and libs.
| |
− | To make Boost visible to compiler, you can simply copy
| |
− | * all the boost .lib's (by default from boostfolder/boost_1_x_y/stage/lib) to the libs/ subfolder in your main VCMI directory
| |
− | * folder "boostfolder/boost_1_x_y/boost" to the includes/ subfolder. Be careful, you need to copy "boost" folder, not its contents!
| |
− | | |
− | = Compiling =
| |
− | Now you should be able to successfully build VCMI. Select "Build solution" from "Build" menu or press F7. Wait until the compilation finishes.
| |
− | | |
− | You should finally see <code class="inline">========== Build: 8 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========</code> message in the IDE output. Built VCMI binaries will be put in the solution folder (C:\VCMI\trunk in our example). If you want to run VCMI somewhere else, open each project properties and adjust "Output Directory" in "General Properties" tab.
| |
− | | |
− | Remember that VCMI_client.exe, VCMI_client.dll and VCMI_server.exe need to be in the same directory and AI (GeniusAI.dll) must be in AI/ subfolder.
| |
− | | |
− | = Running and debugging VCMI =
| |
− | After compilation you should have received new VCMI binaries in your trunk/ folder:
| |
− | * VCMI_client.exe
| |
− | * VCMI_server.exe
| |
− | * VCMI_lib.dll
| |
− | * GeniusAI.dll (in trunk/AI/ subfolder)
| |
− | * StupidAI.dll (in trunk/AI/ subfolder)
| |
− | | |
− | == Running VCMI in a build place (recommended) ==
| |
− | === VCMI files ===
| |
− | Extract package with latest VCMI release to the trunk folder. It contains some content (fonts, graphics, etc) that are not part of SVN repository.
| |
− | <strong>Do NOT overwrite</strong> anything. Files from repository are always most up-to-date and have priority over the ones released some time ago.
| |
− | If you overwrite any file from SVN you can always use Revert command from TortoiseSVN.
| |
− | | |
− | === H3 files ===
| |
− | VCMI needs files with content from H3.
| |
− | Copy:
| |
− | * From the game folder:
| |
− | ** MP3 folder with its contents
| |
− | ** binkw32.dll
| |
− | ** smackw32.dll
| |
− | * From Data subfolder:
| |
− | ** VIDEO.VID
| |
− | ** Heroes3.snd
| |
− | ** h3sprite.lod
| |
− | ** h3bitmap.lod
| |
− | ** H3ab_bmp.lod
| |
− | ** H3ab_ahd.snd
| |
− | ** H3ab_ahd.vid
| |
− | | |
− | You'll also may want to copy some (or all) maps.
| |
− | | |
− | VCMI should be smart enough to give meaningful error message when one of content files is missing. Check the console output or VCMI_client_log.txt if something goes wrong.
| |
− | | |
− | === Libraries ===
| |
− | Additionally, you need to copy all *.dll files from libraries pack (libs/x86) to the trunk folder (or your destination folder of choice).
| |
− | | |
− | == Running VCMI in external folder ==
| |
− | Alternatively, you can simply replace binaries in existing VCMI installation with the ones you've built.
| |
− | In such case you should also replace .txt files in config/ directory with the ones from trunk (and any other relevant files that have changed in SVN).
| |
− | | |
− | It's not very convenient because you need to copy files each time after build. To avoid that necessity you can change Output Directory in properties of all projects. Then binaries you built will be automatically put in the right place.
| |
− | However you would still need to remember about changes in config files. (Some script for copying them used as post-built event may be a good idea here)
| |
− | | |
− | | |
− | == Running / debugging VCMI from IDE ==
| |
− | Visual Studio offers several convenient commands to run / debug project. Before you can use them, you need to set Working Directory to <code class="inline">$(OutDir)</code> in project properties for VCMI_client.
| |
− | | |
− | [[File:workingDir.png|250px]]
| |
− | | |
− | Now you can start debugging by:
| |
− | * Using Start Debugging (F5) command - starts game with debugger attached
| |
− | * Using Step Over/Into (F10 or F11) command - starts game and stops at the beginning of main function, allowing line-by-line execution
| |
− | * Running VCMI normally and attaching debugger to its process
| |
− | | |
− | To debug server, you need to attach to its process before it crashes; otherwise you will just see an information that server has crashed. No breakpoints in its code will be hit. However, in Visual Studio Professional or higher there is possibility to attach to server after is crashes.
| |
− | | |
− | = Further help =
| |
− | If you need any further help, ask at [http://forum.vcmi.eu our forums].
| |