03-31-2016, 05:06 PM
New Way
With a nice C++ package manager from Microsoft and VS >=2015 support for CMake projects, the prebuilt packages are no longer needed.
Installing tools and dependencies
Note that we're doing static building in order to avoid problems with DLLs. If you want to do a dynamic build, use triplet without -static suffix and remove the -D?_STATIC variables from CMakeSettings.json. Be prepared for having issues with that though. Some DLLs are copied automatically and some are not.
Do the following:![[Image: cca9zMB.png]](https://i.imgur.com/cca9zMB.png)
Follow the instructions to install vcpkg and in the root of the directory where you downloaded it, run this command:
vcpkg.exe install boost sdl2 sdl2-ttf sdl2-image glew libpng libwebp tiff gettext libsndfile libvorbis libogg openal-soft physfs --triplet x86-windows-static
Note: For x64 support, change to --triplet x64-windows-static to the command above.
![[Image: sg7Rd8b.png]](https://i.imgur.com/sg7Rd8b.png)
Clone or download the Colobot source code, preferably using git. You also need Colobot data source. Note: This way is currently supported only by dev branch. For any other branch, you must use the old way or wait until they merge with dev.
Unfortunately, the necessary command line tools need to be installed manually, unless there is another package manager with them that I'm not aware of. Download the following in form of ZIPs:
![[Image: YBEwsCX.png]](https://i.imgur.com/YBEwsCX.png)
![[Image: Tk2m5cV.png]](https://i.imgur.com/Tk2m5cV.png)
Compiling Colobot
You probably want to launch Colobot with some command line parameters. Use the menu CMake -> Debug and Launch Settings -> colobot.exe (install) and in the opened file add "args": ["-param1", "-param2", ..., "-paramN"] to the "configurations" object.
![[Image: 7ZgKfuI.png]](https://i.imgur.com/7ZgKfuI.png)
![[Image: ZaEk8FP.png]](https://i.imgur.com/ZaEk8FP.png)
Old Way
With a nice C++ package manager from Microsoft and VS >=2015 support for CMake projects, the prebuilt packages are no longer needed.
Installing tools and dependencies
Note that we're doing static building in order to avoid problems with DLLs. If you want to do a dynamic build, use triplet without -static suffix and remove the -D?_STATIC variables from CMakeSettings.json. Be prepared for having issues with that though. Some DLLs are copied automatically and some are not.
Do the following:
- Install Visual Studio with at least the following workloads:
- Desktop development with C++ (it provides the CMake support among other things)
- Python development (unless you already have Python >=2.7 installed)
- Game development with C++ (not sure if it's needed actually, but better safe than sorry)
![[Image: cca9zMB.png]](https://i.imgur.com/cca9zMB.png)
vcpkg.exe install boost sdl2 sdl2-ttf sdl2-image glew libpng libwebp tiff gettext libsndfile libvorbis libogg openal-soft physfs --triplet x86-windows-static
Note: For x64 support, change to --triplet x64-windows-static to the command above.
![[Image: sg7Rd8b.png]](https://i.imgur.com/sg7Rd8b.png)
- gettext (take content of bin/) obligatory
- oggenc (rename oggenc2.exe to oggenc.exe) for converting music
- wget for downloading music, if you don't care just remember to add -DMUSIC=0 to CMake parameteres (in the next section)
- rsvg-convert for desktop icons
- xmlstarlet (rename xml.exe to xmlstarlet.exe) for desktop icons
![[Image: YBEwsCX.png]](https://i.imgur.com/YBEwsCX.png)
![[Image: Tk2m5cV.png]](https://i.imgur.com/Tk2m5cV.png)
Compiling Colobot
- Open Visual Studio.
- From the menu choose File -> Open -> CMake..., then select the CMakeLists.txt file in the root of the Colobot source code directory. At this point there will be errors in the output window, don't worry about that just yet.
- CMake -> Change CMake Settings -> CMakeLists.txt. A new file CMakeLists.json will open with at least 4 configurations (x86/x64-release/debug). Set:
- cmakeCommandArgs to "-DCMAKE_TOOLCHAIN_FILE={{PATH_TO_VCPKG}}/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x86-windows-static -DBOOST_STATIC=1 -DGLEW_STATIC=1 -DMSVC_STATIC=1". You can add other parameters here too, like -DDEV_BUILD=1 or -DMUSIC=0.
- configurationType to "Release" if for some reason it is set to "RelWithDebInfo" or something else (it simply doesn't work, I don't know why).
- In the top toolbar, choose the correct configuration (x86/x64-debug/release). Use "release" if you want a clean build like the one you can download from the official webpage. For development I recommend "debug".
- CMake -> Cache -> Delete Cache Folders, then CMake -> Cache -> Generate. There should be no errors. If there are, then I'm afraid you're on your own. Make sure you've done everything so far correctly. Ask for help the community if you need.
- Next to the configuration option from step 4 there now should be a button with green arrow. Choose "colobot.exe (install)" (because we want to install the data files) and click the green arrow. You can also use Build -> Build Solution if you don't want to run the game after the build. You can probably use "colobot.exe" without "(install)" if you don't change the data files frequently.
- Enjoy the game!
You probably want to launch Colobot with some command line parameters. Use the menu CMake -> Debug and Launch Settings -> colobot.exe (install) and in the opened file add "args": ["-param1", "-param2", ..., "-paramN"] to the "configurations" object.
![[Image: 7ZgKfuI.png]](https://i.imgur.com/7ZgKfuI.png)
![[Image: ZaEk8FP.png]](https://i.imgur.com/ZaEk8FP.png)
Old Way
Spoiler :
You can build Colobot: Gold Edition using Microsoft Visual Studio since 2013 version.
What it comes down to: Just follow the regular instructions from the repository, under "Compiling on Linux" section, except the "apt-get" part and other Linux-specific stuff. Follow the guide below for this.
First of all, configuring C++ development environment on Windows is not easy. Make sure you want to do this and consider other options, MSYS2, MinGW or even setting up Linux on your computer with dual boot or on a Virtual Machine.
If you're still reading this, I assume you want to build Colobot with MSVC.
The obstacle here is installing all the necessary dependencies. On any sane Linux system, there is a package manager which usually means that installing all the necessary dependencies is as easy as copy pasting a command. On Windows there is no such package manager out of the box and the ones that exist usually don't have a lot of packages and need some configuration. This means that you need to install every dependency manually and it wouldn't sound so bad except that you probably need to build some of those dependencies yourself.
However, fear not! You're not the only person who worked with MSVC on Colobot. Those people created a package with almost all the things you need to build Colobot. So, if you're not an experienced C++ programmer, you're better off downloading one of those packages instead of trying to make everything work by yourself. Unless you want to learn something.
That said, if you manage to make a working development environment for MSVC without using one of the packages below, then please create such a package, upload it somewhere and post the link in this thread so more people can use it. The first post should list all the working packages available. Let know if you find dead links.
Available packages:
What it comes down to: Just follow the regular instructions from the repository, under "Compiling on Linux" section, except the "apt-get" part and other Linux-specific stuff. Follow the guide below for this.
First of all, configuring C++ development environment on Windows is not easy. Make sure you want to do this and consider other options, MSYS2, MinGW or even setting up Linux on your computer with dual boot or on a Virtual Machine.
If you're still reading this, I assume you want to build Colobot with MSVC.
The obstacle here is installing all the necessary dependencies. On any sane Linux system, there is a package manager which usually means that installing all the necessary dependencies is as easy as copy pasting a command. On Windows there is no such package manager out of the box and the ones that exist usually don't have a lot of packages and need some configuration. This means that you need to install every dependency manually and it wouldn't sound so bad except that you probably need to build some of those dependencies yourself.
However, fear not! You're not the only person who worked with MSVC on Colobot. Those people created a package with almost all the things you need to build Colobot. So, if you're not an experienced C++ programmer, you're better off downloading one of those packages instead of trying to make everything work by yourself. Unless you want to learn something.
That said, if you manage to make a working development environment for MSVC without using one of the packages below, then please create such a package, upload it somewhere and post the link in this thread so more people can use it. The first post should list all the working packages available. Let know if you find dead links.
Available packages:
- (From @Simbax ) (tested on MSVC 2013, Win32) Download (Note: set BOOST_STATIC to 1 in CMake)
- (From @Simbax ) (tested on MSVC 2015, Win64, debug, dynamic linking) Download (Note: set BOOST_STATIC to 1 in CMake)
- (From @Smok ) (tested on MSVC 2013, Win32) Download (Note: set BOOST_STATIC to 1 and MUSIC to 0 in CMake)
- All necessary files for successful CMake build
- All necessary files for successful compilation of the code
- All necessary files for running the game (e.g. the DLLs)
- Eventually all necessary files for successful build of translations, music etc.
- Instructions for installing if they are different than the ones below
- Of course, you must install Visual Studio first, preferably the version the package was tested on, but it might work on newer versions too. Make sure it's at least 2013. During the installation you will probably be asked what components to install, obviously choose C++.
- Download ZIP of the source code of Colobot on any branch you want (master for stable builds, dev for newer builds), or preferably clone it with git (this is not a tutorial about git, read the book if you want to use it), especially if you want to contribute to our project. Unpack it anywhere you want, in the guide I assume it's in a colobot-repo directory.
- Install CMake.
- Download one of the packages listed above and unpack it to some directory (e.g. C:\Dev\colobot-dependencies).
- In the package there should be a folder bin. Add the path to it to the PATH environment variable. Read an answer here or google it if you don't know how or why.
- Create colobot-repo\build directory or anywhere you want to keep the "dirty" build temporary files. This folder is also where there will be a project you can open with Visual Studio. cd to it if you are using command line or open it with cmake-gui if you prefer the GUI.
- Run cmake with variables set properly according to the package and your environment (you set them up in the GUI or with parameters to the command line):
- Choose the generator which matches your Visual Studio installation (e.g. Visual Studio 12 2013)
- CMAKE_PREFIX_PATH = path to the directory where you unpacked the package, (e.g. C:\Dev\colobot-dependencies)
- CMAKE_BUILD_TYPE = Release or Debug
- You can also add other configuration variables of course, look in the readme files in the repository for more information.
- Example command: cmake -G"Visual Studio 12 2013" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=C:\Dev\colobot-dependencies -DCMAKE_INSTALL_PREFIX=C:\Dev\colobot-bin ..
- Hopefully the build is successful, otherwise you must fix any errors (you can probably ignore warnings unless you don't want to) yourself. Common errors are wrong paths, wrong values, or simply the package doesn't work with the Visual Studio version you are using. You can safely delete the build if you want to start fresh. Anyway, after successful CMake run you can open the generated colobot-repo\build\colobot.sln file using Visual Studio.
- In the Visual Studio, set the correct build preset in the toolbar (e.g. Debug 64-bit or Release 32 bit, depending on your system and the package). The should be several projects listed in sidebar. Sorry there are no pictures in this guide, I'll add them at some point.
- Build Colobot the first time using the INSTALL project. It should build and "install" the game to the chosen directory (CMAKE_INSTALL_PREFIX), which you can set in CMake. Note: if you encounter problems during copying files to the installation directory (but everything builds correctly), then make sure you have proper privileges for writing in the installation directory (C:/Program Files is not one of such places). If everything is good, there should be colobot.exe in the installation directory, so go ahead and run it.
- If you want to run the game directly from MSVC (e.g. for debugging) you should set the colobot project as the main one. You may also need to edit the debug settings in order to add some parameters or to set the working directory to the one where you have the data files installed (e.g. using the INSTALL project).
- You should finally enjoy/test/develop the game using your own Windows build.