Ever wondered to have a good IDE for C++ with beautiful dark theme and essential features? Stuck on editors like DevC++ & Codeblocks?. Well, If you are familiar with VSCode, and if you want to write some C++ Code for Competitive Coding, then this blog is for you.
SETUP
- Install VSCode
- Install Microsoft C/C++ extension. You can install the C/C++ extension by searching for ‘c++’ in the Extensions view (Ctrl+Shift+X)
- Install Mingw-w64
Mingw-w64 Setup Settings:
Version: Latest
Architecture: Run Following command in cmd:
If Output is
x86-based PC
selecti686
else if output is
x64-based PC
selectx86-64
Threads: posix
Exception: seh
Build Version: 0
DEBUG HELLO WORLD
- Create a new folder
Hello World
and createhelloworld.cpp
in that folder. Open that folder in vscode.
- Go to Main menu > Terminal > Configure Default Build Task >
g++.exe build active file
(if not shown, restart vscode) - Open
helloworld.cpp
and pressctrl + shift + B
to build - Press F5 > Run > Add Configuration… > C++ (GDB/LLDB) >
g++.exe build and debug active file
- Open
launch.json
just created by above step and do following steps:
1) Add following configuration: "targetArchitecture": "x86_64"
[2]
2) Change following configuration: "externalConsole": true
- Add a breakpoint and debug
REFERENCES
- [1] https://code.visualstudio.com/docs/cpp/config-mingw
- [2] https://github.com/microsoft/vscode-cpptools/issues/2376