1. Download the Visual Studio Code, install the website. Follow the prompts to install the CPP plugin and the CMake plugin.
Download CMake, install the website.
Download Mingw, install the website.
When installing MINGW, be careful to tick mingw32-automake, Mingw32-base, MINGW32-GCC, mingw32-gcc-g++, Msys-base, Mingw32-binutils, Mingw32-gdb.
2. File->open folder to open the project directory.
The directory for the folder should be
ProjectDir
- src/ #project source
- lib/ #project dependencies
- doc/ #project documentation
- build/ #build directory
3. Create the corresponding CMakeLists.txt file in each directory, open the CMake, set the source code directory to ProjectDir, set the build directory to Projectdir/build, click Configure, select Gene Rator for Mingw Makefile, set Cmake_build_type to Debug, then point Generate, Generate Makefile, and then in CMD CD to build directory, run Mingw32-make, in B In, an executable file is available.
4. In Visual Studio Code, click on the Fourth button on the left, which is the Debug button, press run, select C + + (GDB/LLDB) will generate a Launch.json file in the. Vscode directory, change the file "program" to "${workspaceroot}/build/bin/xx.exe", change "Midebuggerpath" to "C:\\mingw\\bin\\gdb.exe". Then set the breakpoint, run, you can debug it.
Reference:
Http://www.cnblogs.com/ode/archive/2011/08/01/2143541.html
http://blog.csdn.net/dbzhang800/article/details/6314073
Workflow for writing C + + in Visual Studio code