Build SuperTux with vcpkg and Visual Studio Code

I watched recent You Tube video: C++ Development with Visual Studio Code with Julia Reid.

https://www.youtube.com/watch?v=WqXrYfSKJXk

In the video, Julia shows how to use Visual Studio Code to build and even debug SuperTux2 video game:

SuperTux2 https://www.supertux.org/

It was interesting how to build this nice game with Visual Studio Code. I have used it for demo samples as I have used Visual Studio Community Edition to build more complex projects.

I followed the Video and I was surprised what easy was to build and generate such game:

This is my own build:

SuperTux built with Visual Studio Code

However, it was not that clear in Julia┬┤s video how to sort out all the issues faced when trying to build SuperTux from scratch.

So, before being successful to get SuperTux running as in screenshot I had to troubleshoot.

This post details what I did to get same results that Julia.

What is assumed is that you already installed Visual Studio Code:

https://code.visualstudio.com/download

Visual Studio Build Tools:

https://visualstudio.microsoft.com/visual-cpp-build-tools/

cmake Visual Studio Extension:

CMake extension

Then you clone SuperTux repository and open the project with Visual Studio Code.

Keep in mind that you need to use –recurse option or submodule option. Look in SuperTux wiki to clone correctly repoi.

At this part the video skips a lot of explanation.

Julia explains how to set the active key to Visual Studio Tools 2019 – amd64

She also explains how to setup build variant to Cmake: Debug Ready

At this point the build config is done but if you try to follow this sequence you will see this kind of error:

Missing dependencies

This error means that all third party libraries used by SuperTux are not installed in your system. In Julia’s case, she already installed those dependencies with vcpkg. So at this point is important to mention that we need to install vcpkg!

Clone vcpkg repo from:

https://github.com/microsoft/vcpkg.git

Go to git folder and run:

bootstrap-vcpkg.bat 

to build vcpkg.exe.

Then run:

vcpkg integrate install

Note the message displayed:

Path to add to settings.json

At this point, setup cmake configuration to point cmake to vcpkg. Open cmake extension settings from Visual Studio Code and setup settings.json. Notice that path is the same that the one displayed by vcpkg integrate install.

{
"cmake.configureSettings": {
"CMAKE_TOOLCHAIN_FILE": "C:/GitHub/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_BUILD": "ON"
},
"cmake.ctestPath": "",
"cmake.copyCompileCommands": "",
"cmake.configureOnOpen": false,
"cmake.generator": ""
}

Then, to enable tab completion:

vcpkg integrate powershell

Then install manually with vcpkg the dependencies. These are mentioned in video and also posted in INSTALL.md file:

“sdl2”, “sdl2-image”, “openal-soft”, “curl”, “libogg”, “libvorbis”, “freetype”, “glew”, “boost-date-time”, “boost-filesystem”, “boost-format”, “boost-locale”, “boost-system”, “physfs”

vcpkg install --triplet windows-64 sdl2

vcpkg will install by default 32 bits packages. By using the –triplet parameter you will install 64 bits version of packages instead of 32 bits.

Every time you install a package, click on the build gear button to generate cmake build file. You will get new error mentioning missing library/package. Once you generate successfully the build the tool will try to build SuperTux. Then you will get error that .lib files are missing

Those libs are provided by same project. Build them manually one by one. Select the target:

Select subproject or target

Then build every single target. lib files will be built.

Finally select SuperTux2 target. This will build exe file.

In my case, when trying to run or debug nothing happened. I launched manually exe file generated in build folder an error message showed that 2 dlls were not found:

squirrel.dll and sqstdlib.dll

Copy 2 dlls into build debug folder.

Finally, I wanted to try vcpkg.json manifest file support. I only found that feature included in latest roadmap:

UPDATE:

I downloaded latest version 0.6.2 from git and then I followed my own steps. I got a different error when running cmake configure. Specifically with physfs_lib package

This time was more difficult to troubleshoot this issue. At the end I commented this line (940) from CMakeLists.txt:


This was not elegant but at the end allowed me to run cmake configure.

After that, the BUILD ALL option worked correctly and I did not have to create every submodule one by one.

Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *