C++ programming with Visual Studio Code (Using gcc/g++ with MinGW)
To use the GCC (g++) C/C++ compiler and GDB debugger from mingw-w64, this tutorial teach you about how to install the MinGW and C/C++ extension for VS Code.
Prerequisites
Install Visual Studio Code and C/C++ extension for VS Code
Open MinGW Installation Manager, and mark “mingw32-base” and “mingw32-gcc-g++” for installation.
Click “Apply Changes” and “Apply”.
Click “Apply”.
Wait for the installation.
Add the MinGW path to the Windows PATH environment
Open your Windows Settings.
Search “Edit environment variables for your account (編輯您的帳戶的環境變數)”.
Choose the “Path” in user variables, and edit it.
Open your MinGW directory path which you select above to the system path, and copy the path of the bin folder.
Select “New” to add the path of your bin folder under the MinGW directory path.
Select “OK” to save the updated path.
Check your MinGW installation
Search “cmd”, and open “Command prompt (命令提示字元)”.
Type following command:
1
2
3
gcc --version
g++ --version
gdb --version
If you don’t see the version information or the command is not recognized, please check your “path” of MinGW folder and make sure your installation process correctly.
Press Ctrl+Shift+B and select “C/C++: gcc.exe” or “C/C++: g++.exe” to build your code.
You will find the .exe file in the workspace.
Press Ctrl+Shift+` to open terminal, and type .\FileName.exe to run the executable file.
Congratulation! You have completed the basic environment construction. If there is a problem with your compilation step, stay tuned for the next tutorial update. ^_−☆