Skip to content

Instantly share code, notes, and snippets.

Last active June 4, 2023 14:18
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
msys2 vscode integration c++ vcpkg cmake
MSYS2 Setup
1. Install MSYS2
2. Follow normal install instructions, update packages with pacman etc.
3. Add the following directories to PATH :
4. Run the following commands in a MSYS2 console:
pacman -S --needed git base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang mingw-w64-x86_64-cmake
cd /mingw64/bin
ln -s mingw32-make.exe make.exe
1. Install VSCode
2. Left click on Extensions on left sidebar, then search and install the C/C++ Extension Pack from Microsoft
3. Press F1 to open the Command Palette, type: settings json
pick the option "Preferences: Open Workspace Settings(JSON)"
4. [THIS IS AN OPTIONAL STEP TO HAVE MSYS2 as an integrated terminal in VSCode]
Copy/paste the settings.json file in this gist.
Terminal->New terminal. An MSYS2 MINGW64 terminal will open. Verify the following on the prompt:
5. Type the following in a Windows Command Prompt to verify installation:
g++ --version
g++ -dumpmachine
make --version
cmake --version
6. In this gist, you will find main.cpp and CMakeLists.txt. Include them in your project.
7. Press F1 to open the Command Palette: cmake edit
pick "CMake: Edit User-Local CMake Kits"
8. Append to the list with a comma, the fragment from cmake-tools-kits.json in this append. Do not overwrite the entries all ready
9. Where it says "No active kit" on the CMake toolbar at the bottom of the screen. select it and you should see the entry just created
"Mingw64 GCC 11.2.0" (if not, click Scan Kits)
10. To build, click Build on the CMake toolbar at the bottom of the screen.
11. To run, click the play button on the CMake toolbar at the bottom of the screen.
install vcpkg in msys2 mingw64
1. Open MSys2 MingW64 variant of the console.
or type: source shell mingw64
cd /mingw64/bin
git clone
cd vcpkg
export VCPKG_DEFAULT_TRIPLET=x64-mingw-dynamic
export VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-dynamic
To test setup
./vcpkg install zlib
This command ends with:
The package zlib is compatible with built-in CMake targets:
find_package(ZLIB REQUIRED)
target_link_libraries(main PRIVATE ZLIB::ZLIB)
For the real deal
./vcpkg install libtcod
"name": "Mingw64 GCC 11.2.0",
"compilers": {
"C": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"CXX": "C:\\msys64\\mingw64\\bin\\g++.exe"
"preferredGenerator": {
"name": "MinGW Makefiles"
"environmentVariables": {
"CMT_MINGW_PATH": "C:\\msys64\\mingw64\\bin",
"VCPKG_TARGET_TRIPLET": "x64-mingw-static"
"toolchainFile": "C:\\msys64\\mingw64\\bin\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
cmake_minimum_required(VERSION 3.10)
project (roguelike-firststab)
set(SDL2_DIR "C:/msys64/mingw64/bin/vcpkg/installed/x64-mingw-static/share/sdl2")
set(glad_DIR "C:/msys64/mingw64/bin/vcpkg/installed/x64-mingw-static/share/glad")
set(lodepng-c_DIR "C:/msys64/mingw64/bin/vcpkg/installed/x64-mingw-static/share/lodepng-c")
set(libtcod_DIR "C:/msys64/mingw64/bin/vcpkg/installed/x64-mingw-static/share/libtcod")
find_package(libtcod CONFIG REQUIRED)
add_executable(roguelike-firststab main.cpp)
target_link_libraries(roguelike-firststab PRIVATE libtcod::libtcod)
# message(STATUS "Downloading CPM.cmake")
# VERSION 2.0.18
#if (SDL2_ADDED)
# add_library(SDL2::SDL2 ALIAS SDL2)
#include <fmt/core.h>
int main() {
fmt::print("Such a relief when it works!\n");
#include <iostream>
int main() {
auto hello = "Hello World\n";
std::cout << hello;
"": {
"msys2": {
"path": [
"args": [
"env": {
"": "msys2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment