Msys2 offers the same tools as Linux to build software on Windows.
-
Download and install MSYS2 (page,installer). You can also use package managers like
ChocolateyorScoopto install MSYS2: Use this command to install with Chocolatey:choco install msys2
Use this command to install with scoop:
scoop install msys2
-
Lunch a bash shell from
cmdC:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64
-
Install
gitpacman -S git
-
Install
gccpacman -S mingw-w64-ucrt-x86_64-gcc
-
Install
ninjapacman -S mingw-w64-ucrt-x86_64-ninja
-
Install
cmakepacman -S mingw-w64-ucrt-x86_64-cmake
-
Install Visual Studio Code.
-
Install C/C++ Extension Pack for Visual Studio Code. You can also install from commandline
code --install-extension ms-vscode.cpptools-extension-pack
-
The next step is to clone starting repository
git clone https://github.com/hkinke/gscppmsys2.git hello
-
Change the folder, remove
.gitfolder, and start a new repositorycd hello rm -rf .git git init -
Change the replace
gscppmsys2inCMakeLists.txtwith the name of your project by examplehello.cmake_minimum_required(VERSION 3.18) project(hello) add_executable(main main.cpp)
-
From Visual Studio Code, choose the
UCRT64kit, configure, and build your project. -
Lunch you application (you can use Visual Studio Code integrated terminal
Ctrl+Shift+`)./build/main
which gives the output
hello from Msys2