Colobot Forum - International Colobot Community
Microsoft Visual Studio Building - Printable Version

+- Colobot Forum - International Colobot Community (
+-- Forum: [Archive] New forum (2015-2019) (
+--- Forum: Colobot: Gold Edition Development (
+---- Forum: Game Engine & General Talk (
+---- Thread: Microsoft Visual Studio Building (/showthread.php?tid=753)

Microsoft Visual Studio Building - Simbax - 03-31-2016

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:
  • 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]
  • 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]
  • 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:
  • 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
Create a directory, e.g. C:\bin, and put there the exe (and dll files if needed) of the above programs, then add this directory to the PATH environment variable (read an answer here if you don't know how or why).

[Image: YBEwsCX.png]
[Image: Tk2m5cV.png]

Compiling Colobot

  1. Open Visual Studio.
  2. 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.
    [Image: q2TzEC8.png]
    [Image: z8mBJcX.png]
  3. 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).
  4. [Image: WmBeEL6.png]
    [Image: K1VnjVy.png]
  5. 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".
    [Image: vqEa6Ey.png]
  6. 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.
    [Image: 35nvDv2.png]
    [Image: IRAlqWs.png]
  7. 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.
    [Image: 2CIJ7Sr.png]
    [Image: 3tCkEPm.png]
    [Image: NO8LioA.png]
  8. Enjoy the game!
    [Image: 6uHpZzm.png]
Launching with arguments

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]
[Image: 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:
  • (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)

Content which should be provided in the packages:
  • 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

  1. 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++.
  2. 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.
  3. Install CMake.
  4. Download one of the packages listed above and unpack it to some directory (e.g. C:\Dev\colobot-dependencies).
  5. 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.
  6. 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.
  7. 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.
  8. 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 ..
  9. 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.
  10. 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.
  11. 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.
  12. 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).
  13. You should finally enjoy/test/develop the game using your own Windows build.
If you encounter any issues, please make a separate thread or ask for help on our IRC channel. Make sure to contain information about which package did you use and what you already did in order to solve the problem.

RE: Microsoft Visual Studio Building - Smok - 04-09-2016

My actuall: (tested on MSVC 2013, Win32) (Note: set BOOST_STATIC to 1 and MUSIC to 0  in CMake)

RE: Microsoft Visual Studio Building - DavivaD - 02-05-2017

(04-09-2016, 10:06 PM)Smok Wrote: My actuall: (tested on MSVC 2013, Win32) (Note: set BOOST_STATIC to 1 and MUSIC to 0  in CMake)

File not found...

RE: Microsoft Visual Studio Building - Smok - 02-05-2017

File found. Just click the damn link.

RE: Microsoft Visual Studio Building - tomangelo - 02-05-2017

I can confirm, link is valid.

RE: Microsoft Visual Studio Building - DavivaD - 02-05-2017

Now it works... Damn Google... Pranks me

RE: Microsoft Visual Studio Building - Berserker - 12-16-2017

Dropbox link is dead and google doesn't allow downloading the zip package due to virus infection.

RE: Microsoft Visual Studio Building - Berserker - 12-26-2017

(12-19-2017, 09:04 AM)immibis Wrote: Try following the instructions instead?
I fail to see how following the instructions solves the dead links issue. Especially since step 2. tells you to unpack the package.

RE: Microsoft Visual Studio Building - AntonK - 05-05-2018

I've finally managed to set up a build environment from scratch on Windows 7 with Visual Studio 2017 (using the toolset v140). I wasn't using pre-build packs of dependent libraries (some of the links in this post seem to be dead), so the task turned out to be a pain in the neck quite burdensome... so I'm thinking about a way how to automate this initial step.
One of the options is to use a tool to automatically download (and optionally build) required libraries. Since the application already uses CMake-scripts, the good candidate to ease the automation is Hunter. I believe, this tool can also fetch dependencies for other platforms...
Is it worth investing time in such a task?
Theoretically when properly implemented the automated dependencies fetching can make it easy for new developers to join the project.

RE: Microsoft Visual Studio Building - Simbax - 06-02-2018

I've updated the first post. The links are no longer dead and I added more details to all the steps for people who are not programmers. It's still far from perfect, I'm going to add some pictures and more details later on.

I don't know about Hunter, but I was hoping to add NuGet support to our CMake build file just for MSVC at some point, as this is probably the easiest and most native way to install dependencies in MSVC projects.

UPDATE: I've described a new way to configure VS for Colobot in the first post.