Copy files below into .vscode\ inside your project folder
Last active
September 11, 2022 19:06
-
-
Save brccabral/a07b44ce8306503aed21f0cd3a5b6cc7 to your computer and use it in GitHub Desktop.
VSCode C++ setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put this file in ${workspace}/.vscode/launch.json | |
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "g++ build and debug main", | |
"type": "cppdbg", | |
"request": "launch", | |
"program": "${workspaceFolder}/${workspaceFolderBasename}", | |
"args": [], | |
"stopAtEntry": false, | |
"cwd": "${workspaceFolder}", | |
"environment": [], | |
"externalConsole": false, | |
"MIMode": "gdb", | |
"setupCommands": [ | |
{ | |
"description": "Enable pretty-printing for gdb", | |
"text": "-enable-pretty-printing", | |
"ignoreFailures": true | |
} | |
], | |
"preLaunchTask": "g++ build main" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put this file in ${workspace}/.vscode/launch.json | |
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "g++ build and debug active file", | |
"type": "cppdbg", | |
"request": "launch", | |
"program": "${workspaceFolder}/main-sfml-app", | |
"args": [], | |
"stopAtEntry": false, | |
"cwd": "${workspaceFolder}", | |
"environment": [], | |
"externalConsole": false, | |
"MIMode": "gdb", | |
"setupCommands": [ | |
{ | |
"description": "Enable pretty-printing for gdb", | |
"text": "-enable-pretty-printing", | |
"ignoreFailures": true | |
} | |
], | |
"preLaunchTask": "g++ build sfml-app", | |
"miDebuggerPath": "/usr/bin/gdb", | |
"envFile": "${workspaceFolder}/.vscode/project.env" // LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put this file in ${workspace}/.vscode/tasks.json | |
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"type": "shell", | |
"label": "g++ build main", | |
"command": "/usr/bin/g++", | |
"args": [ | |
// "-std=c++17", // SFML-3.x | |
"-g", // needed for debuging | |
"-c", // compile and assemble, but do not link | |
"${workspaceFolder}/main.cpp", | |
"-o", // output to | |
"${workspaceFolder}/main.o" | |
], | |
"options": { | |
"cwd": "/usr/bin" | |
}, | |
"problemMatcher": [ | |
"$gcc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": false | |
} | |
}, | |
{ | |
"type": "shell", | |
"label": "g++ build sfml-app", | |
"command": "/usr/bin/g++", | |
"args": [ | |
// "-std=c++17", // SFML-3.x | |
"-g", // needed for debuging | |
"${workspaceFolder}/main.o", | |
"-o", // output to | |
"${workspaceFolder}/main-sfml-app", | |
"-lsfml-graphics-d", | |
"-lsfml-window-d", | |
"-lsfml-system-d", | |
// "-L/usr/local/lib" // SFML-3.x | |
], | |
"options": { | |
"cwd": "/usr/bin" | |
}, | |
"problemMatcher": [ | |
"$gcc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
}, | |
"dependsOn": [ | |
"g++ build main" | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put this file in ${workspace}/.vscode/tasks.json | |
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"type": "shell", | |
"label": "g++ build main", | |
"command": "/usr/bin/g++", | |
"args": [ | |
"-Wall", | |
"-Wextra", | |
"-Werror", | |
"-g", // needed for debuging | |
"main.cpp", | |
"-o", // output to | |
"${workspaceFolderBasename}" | |
], | |
"options": { | |
"cwd": "${workspaceFolder}" | |
}, | |
"problemMatcher": [ | |
"$gcc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "build and debug main", | |
"type": "cppdbg", | |
"preLaunchTask": "g++ build and link main", | |
"request": "launch", | |
"program": "${workspaceFolder}/main", | |
"args": [], | |
"stopAtEntry": false, | |
"cwd": "${workspaceFolder}", | |
"environment": [], | |
"externalConsole": false, | |
"MIMode": "gdb", | |
"setupCommands": [ | |
{ | |
"description": "Enable pretty-printing for gdb", | |
"text": "-enable-pretty-printing", | |
"ignoreFailures": true | |
}, | |
{ | |
"description": "Set Disassembly Flavor to Intel", | |
"text": "-gdb-set disassembly-flavor intel", | |
"ignoreFailures": true | |
} | |
] | |
}, | |
{ | |
"name": "debug only main", | |
"type": "cppdbg", | |
"request": "launch", | |
"program": "${workspaceFolder}/main", | |
"args": [], | |
"stopAtEntry": false, | |
"cwd": "${workspaceFolder}", | |
"environment": [], | |
"externalConsole": false, | |
"MIMode": "gdb", | |
"setupCommands": [ | |
{ | |
"description": "Enable pretty-printing for gdb", | |
"text": "-enable-pretty-printing", | |
"ignoreFailures": true | |
}, | |
{ | |
"description": "Set Disassembly Flavor to Intel", | |
"text": "-gdb-set disassembly-flavor intel", | |
"ignoreFailures": true | |
} | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"type": "cppbuild", | |
"label": "g++ build and link main", | |
"command": "/usr/bin/g++", | |
"args": [ | |
"-g", | |
"*.cpp", | |
"-o", | |
"${workspaceFolder}/main", | |
"-I", | |
"./src/graphics", | |
"./src/graphics/*.cpp", | |
"-lglfw3", | |
"-lGL", | |
"-lGLU", | |
], | |
"options": { | |
"cwd": "${workspaceFolder}" | |
}, | |
"problemMatcher": [ | |
"$gcc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
}, | |
"detail": "g++ main" | |
}, | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put this file inside your project .vscode/c_cpp_properties.json if you want to use www.winlibs.com compiler | |
{ | |
"configurations": [ | |
{ | |
"name": "Win32", | |
"includePath": [ | |
"${workspaceFolder}/**", | |
"C:/mingw64/x86_64-w64-mingw32/include", | |
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.1.0/include" | |
], | |
"defines": [ | |
"_DEBUG", | |
"UNICODE", | |
"_UNICODE" | |
], | |
"compilerPath": "C:\\mingw64\\bin\\gcc.exe", | |
"cStandard": "c17", | |
"cppStandard": "c++17", | |
"intelliSenseMode": "gcc-x64" | |
} | |
], | |
"version": 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put this file in ${workspace}/.vscode/launch.json | |
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "debug with gdb", | |
"type": "cppdbg", | |
"request": "launch", | |
"program": "${workspaceFolder}\\${workspaceFolderBasename}.exe", | |
"args": [], | |
"stopAtEntry": false, | |
"cwd": "${workspaceFolder}", | |
"environment": [], | |
"externalConsole": false, | |
"MIMode": "gdb", | |
"miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe", | |
"setupCommands": [ | |
{ | |
"description": "Enable pretty-printing for gdb", | |
"text": "-enable-pretty-printing", | |
"ignoreFailures": true | |
}, | |
{ | |
"description": "Set Disassembly Flavor to Intel", | |
"text": "-gdb-set disassembly-flavor intel", | |
"ignoreFailures": true | |
} | |
], | |
"preLaunchTask": "clang++ *.cpp" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"type": "shell", | |
"label": "g++ build and link main", | |
"command": "C:\\mingw64\\bin\\g++.exe", | |
"args": [ | |
"-fdiagnostics-color=always", | |
"-g3", // needed for debuging | |
"-Wall", | |
"\"${workspaceFolder}\\main.cpp\"", | |
"-o", // output to | |
"\"${workspaceFolder}\\${workspaceFolderBasename}.exe\"", | |
"-I", | |
"\"D:\\SFML-2.5.1-mingw\\include\"", | |
"-L", | |
"\"D:\\SFML-2.5.1-mingw\\lib\"", | |
"-lsfml-graphics-d", | |
"-lsfml-window-d", | |
"-lsfml-system-d", | |
], | |
"options": { | |
"cwd": "${workspaceFolder}" | |
}, | |
"problemMatcher": [ | |
"$gcc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
}, | |
"detail": "g++ main.cpp" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the default is clang++ | |
// get compilers g++ and clang++ from https://winlibs.com/ | |
// cl.exe is Microsoft's compiler | |
// to use cl.exe, open Codium from "Developer PowerShell" (codium .) | |
// put this file in ${workspace}/.vscode/tasks.json | |
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "g++ *.cpp", | |
"type": "shell", // "shell" is for using PowerShell, if CMD then "cppbuild" | |
"command": "C:\\mingw64\\bin\\g++", | |
"args": [ | |
"-g", // needed for debugging | |
"-std=c++20", | |
"*.cpp", | |
"-o", | |
"${workspaceFolder}\\${workspaceFolderBasename}.exe" | |
], | |
"options": { | |
"cwd": "${workspaceFolder}" | |
}, | |
"problemMatcher": [ | |
"$gcc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": false | |
}, | |
"detail": "g++ main.cpp" | |
}, | |
{ | |
"label": "clang++ *.cpp", | |
"type": "shell", // "shell" is for using PowerShell, if CMD then "cppbuild" | |
"command": "C:\\Winlibs\\mingw64\\bin\\clang++", | |
"args": [ | |
"-g", // needed for debugging | |
"-std=c++20", | |
"*.cpp", | |
"-o", | |
"${workspaceFolder}\\${workspaceFolderBasename}.exe" | |
], | |
"options": { | |
"cwd": "${workspaceFolder}" | |
}, | |
"problemMatcher": [ | |
"$gcc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
}, | |
"detail": "clang++ main.cpp" | |
}, | |
// to use cl.exe, open Codium from "Developer PowerShell" | |
{ | |
"label": "cl.exe *.cpp MSVC", | |
"type": "shell", // "shell" is for using PowerShell, if CMD then "cppbuild" | |
"command": "cl.exe", | |
"args": [ | |
"/Zi", | |
"/std:c++latest", | |
"/EHsc", | |
"/Fe:", | |
"${workspaceFolder}\\${workspaceFolderBasename}.exe", | |
"${workspaceFolder}\\*.cpp" | |
], | |
"options": { | |
"cwd": "${workspaceFolder}" | |
}, | |
"problemMatcher": [ | |
"$msCompile" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": false | |
}, | |
"detail": "cl.exe main.cpp" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put this file inside your project .vscode/c_cpp_properties.json if you want to use Windows MSVC | |
{ | |
"configurations": [ | |
{ | |
"name": "Win32", | |
"includePath": [ | |
"${workspaceFolder}/**" | |
], | |
"defines": [ | |
"_DEBUG", | |
"UNICODE", | |
"_UNICODE" | |
], | |
"windowsSdkVersion": "10.0.19041.0", | |
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe", | |
"cStandard": "c17", | |
"intelliSenseMode": "windows-msvc-x64", | |
"cppStandard": "c++20" | |
} | |
], | |
"version": 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add to settings.json (global or within project) | |
{ | |
"C_Cpp.default.cppStandard": "c++20", | |
"terminal.integrated.defaultProfile.windows": "PowerShell", | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment