This project builds and runs on both Linux and Windows (via MSYS2).
Install the required tools:
sudo apt update
sudo apt install build-essential gdb make
build-essentialincludesgcc,g++, andmake.
-
Download and install MSYS2 👉 https://www.msys2.org/
-
Open the MSYS2 MinGW 64-bit terminal (not the plain MSYS2 shell).
-
Update and install the required packages:
pacman -Syu
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb makeIf prompted to restart the shell, close and reopen MSYS2 MinGW 64-bit before running the second
pacmancommand.
-
Set up VS Code to use MSYS2:
- Open Command Palette →
Terminal: Select Default Profile→ selectMSYS2 MinGW 64-bit - In
.vscode/launch.json, ensure the Windows debugger path is:
- Open Command Palette →
"miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe"Install these from the VS Code Marketplace:
- C/C++ (by Microsoft) — IntelliSense and debugger
- Makefile Tools (optional but helpful)
From the terminal or using the VS Code build task:
make # Build the project
make run # Build and run the program
make clean # Clean build artifactsIn VS Code:
-
Press
F5or go to Run → Start Debugging -
Choose the correct debug config:
Debug my_c_program (Linux)Debug my_c_program (Windows)
When successful, the program will print:
Hello, cross-platform world!