- Download Mingw-w64.
- Make sure you add its
bin/
folder to the PATH.
Install the compiler and the deBugger :
# For example, on Debain-based systems :
sudo apt install build-essential gdb
Install the compiler and the deBugger :
xcode-select --install
- Visit VSCode.
- Download the Windows-64 'Stable' version.
- Follow the installation steps by running the downloaded file, and check the ADD VSCode to PATH option for sure.
-
Install using
snap
. Choose your distro type in the list to installsnap
. -
snap
is a new global package-manager common to all distros.
# For example, on Debain-based systems :
# To install snap :
sudo apt update
sudo apt install snapd
# To install VSCode :
sudo snap install code --classic
- Visit VSCode.
- Download the MacOS 'Stable' version.
- Follow the installation steps by running the downloaded file
- Search for the C/C++, and C++ Intellisense extensions and install them.
- You get language-support, auto-complete and intellisense features through these extensions.
- Create a
c_cpp_properties.json
file in.vscode/
- Add the following to the file :
{
"configurations": [
{
"name": "Windows",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compilerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe",
"cStandard": "c17",
"intelliSenseMode": "gcc-x64"
},
{
"name": "Linux",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"intelliSenseMode": "gcc-x64"
},
{
"name": "Mac",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
- Create a
tasks.json
file in.vscode/
- Add the following to the file :
{
"version": "2.0.0",
"type": "shell",
// General console config
"presentation": {
"focus": true,
"panel": "shared",
"showReuseMessage": false,
"clear": false,
"echo": true
},
"tasks": [
// Compile Task
{
"type": "shell",
"label": "Compile",
"command": "gcc",
"args": ["-g", "${file}", "-o", "out/${fileBasenameNoExtension}.exe"],
"options": {
"cwd": "${workspaceFolder}"
},
"group": "build",
"linux": {
"command": "/usr/bin/gcc",
"args": ["-g", "${file}", "-o", "out/${fileBasenameNoExtension}.out"]
},
"osx": {
"command": "clang",
"args": ["-g", "${file}", "-o", "out/${fileBasenameNoExtension}"]
}
},
// Run Task
{
"type": "shell",
"label": "Run",
"command": "out/${fileBasenameNoExtension}.exe",
"promptOnClose": false,
"dependsOn": ["Compile"],
"group": {
"kind": "build",
"isDefault": true
},
"linux": {
"command": "out/${fileBasenameNoExtension}.out"
},
"osx": {
"command": "out/${fileBasenameNoExtension}"
}
}
]
}
- Create a
launch.json
file in.vscode/
- Add the following to the file :
{
"configurations": [
{
"name": "deBug",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Compile",
"externalConsole": false,
"internalConsoleOptions": "openOnSessionStart",
"program": "${workspaceFolder}/out/${fileBasenameNoExtension}.exe",
"miDebuggerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gdb.exe"
// "linux": {
// "program": "${workspaceFolder}/out/${fileBasenameNoExtension}.out",
// "miDebuggerPath": "/usr/bin/gdb"
// },
// "osx": {
// "program": "${workspaceFolder}/out/${fileBasenameNoExtension}",
// "miDebuggerPath": "/usr/bin/lldb",
// "MIMode": "lldb"
// }
}
]
}
Happy Coding!