总结一下vs code调试项目时,json文件和task的配置信息。主要包括2种方式。第一种不涉及多文件和makefile。第二种使用到makefile编译调试大型项目。
平台:Ubuntu 16.04 && vs code 1.30.2 && gcc 5.4.0 && g++ 5.4.0
ps: gcc 和 g++ 在ubuntu中默认安装,使用gcc -version 和 g++ version
查看,如果未安装,可以使用sudo apt-get install build-essential 和 sudo apt-get install g++-4.8
1.单个cpp文件调试
以下是为main.cpp文件
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
cout<< "hello world"<< endl;
return 0;
}
以下是launch文件
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch", //使用C++编译器编译
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/hello", //项目生成
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot