vscode with c++ Windows setup
Download & Install Visual Studio Code
Download & Install MinGW-w64
Modify “Architecture” in Settings
Modify “Destination folder” in Installation folder
others default is fine
Download & Install LLVM
Download “Pre-Built Binaries” version
Modify “system PATH” option
Modify “Destination Folder”
Copy data
Copy data in “C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64” to “C:\LLVM”
Install vscode extensions
Create project folder & json file
- Create a project folder, example : “Cpp”.
- Create “.vscode” folder in project folder.
- Add 4 json file in .vscode folder :
- c_cpp_properties.json
{ "configurations": [ { "name": "MinGW", "intelliSenseMode": "clang-x64", "compilerPath": "C:/LLVM/bin/gcc.exe", "includePath": [ "${workspaceFolder}" ], "defines": [], "browse": { "path": [ "${workspaceFolder}" ], "limitSymbolsToIncludedHeaders": true, "databaseFilename": "" }, "cStandard": "c11", "cppStandard": "c++17" } ], "version": 4 }
- launch.json
{ "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "internalConsoleOptions": "neverOpen", "MIMode": "gdb", "miDebuggerPath": "gdb.exe", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": false } ], "preLaunchTask": "Compile" } ] }
- settings.json
{ "files.defaultLanguage": "cpp", "editor.formatOnType": true, "editor.snippetSuggestions": "top", "code-runner.runInTerminal": true, "code-runner.executorMap": { "c": "cd $dir && clang $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -fcolor-diagnostics --target=x86_64-w64-mingw -std=c11 && $dir$fileNameWithoutExt", "cpp": "cd $dir && clang++ $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -fcolor-diagnostics --target=x86_64-w64-mingw -std=c++17 && $dir$fileNameWithoutExt" }, "code-runner.saveFileBeforeRun": true, "code-runner.preserveFocus": true, "code-runner.clearPreviousOutput": false, "C_Cpp.clang_format_sortIncludes": true, "C_Cpp.intelliSenseEngine": "Default", "C_Cpp.errorSquiggles": "Disabled", "C_Cpp.autocomplete": "Disabled", "clang.cflags": [ "--target=x86_64-w64-mingw", "-std=c11", "-Wall" ], "clang.cxxflags": [ "--target=x86_64-w64-mingw", "-std=c++17", "-Wall" ], "clang.completion.enable": true }
- tasks.json
{ "version": "2.0.0", "tasks": [ { "label": "Compile", "command": "clang++", "args": [ "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}.exe", "-g", "-Wall", "-static-libgcc", "-fcolor-diagnostics", "--target=x86_64-w64-mingw", "-std=c++17" ], "type": "shell", "group": { "kind": "build", "isDefault": true }, "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared" } } ] }
- c_cpp_properties.json
Happy coding
- Coding files must be in project folder.
- “Ctrl + Shift + B” to build .exe file.
- “Ctrl + Alt + N” to run.