vscode c++ cmake template project
VSCode configure C++ dev environment
claim
use CMake to build the project.
For debugging, VSCode's CMake plugins needs cmake version >=3.7.1, and ubuntu16.04 apt gives cmake 3.5, thus I don't use VSCode CMake extension. I'll use VSCode's tasks, they are flexible.
steps
create backbone code
Create your codes, including:
- CMakeLists.txt
- compile.sh
- src/
You can copy from my template.
create build and run tasks (tasks.json)
Use Ctrl+Shift+P command, and select >tasks: configure task, then choose other build systems.
Then in tasks.json, write these (including the building and run tasks):
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "CMake build",
"type": "shell",
"command": "./compile.sh",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "run",
"type": "shell",
"command": "./build/blob_demo",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
}
]
}
Then, Ctrl+Shift+P, type Tasks: Run Task, choose build or run tasks that you just created.
debug the program (launch.json)
Since I use cmake to build my project, I set debug mode support in compile.sh, which actually pass -DCMAKE_BUILD_TYPE=Debug to cmake.
Go to debugger button, and add a new configuration, by choosing C++(GDB/LLDB). This will create a launch.json file. Its content would be like this:
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/blob_demo", #!! change here for your config
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Then, in any of your .cpp file, clicking a breakpoint, and in debugging button page, start it.
vscode c++ cmake template project的更多相关文章
- 使用VSCode和CMake构建跨平台的C/C++开发环境
日前在学习制作LearnOpenGL教程的实战项目Breakout游戏时,希望能将这个小游戏开发成跨平台的,支持在多个平台运行.工欲善其事必先利其器,首先需要做的自然是搭建一个舒服的跨平台C/C++开 ...
- VScode 使用 CMake 入门
参考 CMake 入门实战 在 linux 平台下使用 CMake 生成 Makefile 并编译的流程如下: 编写 CMake 配置文件 CMakeLists.txt . 执行命令 cmake PA ...
- vscode+MinGW+cmake设置轻量ide
本地随手写一些题目的时候,发现visual studio非常庞大emmm vscodevscode是一个轻量编辑器 (1)vscode插件与设置自动同步 在两个电脑上,用vscode可以同步插件 ,利 ...
- linux 下 VSCODE 使用CMake编译STM32程序
项目在做什么 项目地址 本项目是为了研究MCU在linux下开发而做的 --build 存放cmake编译生成的文件 --cmake 存放cmake编译时会用到的文件,比如工具链检查.编译选项等 -- ...
- OpenCV300 CMake生成project在项目过程中的问题
2015年6一个月4日本.OpenCV官网上面给出了最新版本号OpenCV.这是:3.0.0版本号,http://opencv.org/ 使用CMake它产生VS2010project流程.我遇到了一 ...
- ubuntu下,VSCode采用cmake编译C++工程
首先在VSCode中下载CMake和CMake Tools两个插件. 选中CMake Tools,可以看到在VSCode中如何使用cmake编译C++工程的教程. 官网教程 最重要且最实用,看这个网址 ...
- 使用Vscode和Cmake打造跨平台的C++ IDE
准备工作 Viusal Studio Code 64位 :Download Visual Studio Code - Mac, Linux, Windows Cmake 3.4 :Download | ...
- Vscode 格式化vue Template代码段
1.安装 vetur 2.在User Setting中增加设置: "vetur.format.defaultFormatter.html": "js-beautify-h ...
- vscode, cmake编译多个C++文件
目的是利用vscode及相关插件编译多个C++文件. 我已经装好cmake和mingw并且将它们的路径添加到系统变量path中了. vscode装上如下几个插件: 点击vscode左上角 文件-& ...
随机推荐
- SpringSecurity项目中如何在多个模块中配置认证信息
⒈在SpringSecurity项目中创建AuthorizeConfigProvider接口用于配置认证信息 package cn.coreqi.ssoserver.authorize; import ...
- 最近邻算法(KNN)
最近邻算法: 1.什么是最近邻是什么? kNN算法全程是k-最近邻算法(k-Nearest Neighbor) kNN算法的核心思想是如果一个样本在特征空间中的k个最相邻的样本中的大多数数以一个类型别 ...
- C++ 模式设计
只写了MinGw/Linux API部分.所有相关的代码都是参考C++ API C++ 11智能指针参考http://blog.csdn.net/zy19940906/article/details/ ...
- CAN总线芯片SN65HVD230QD介绍
CAN总线硬件电路如上,采用芯片为SN65HVD230QD,从TI获得的芯片手册,可知该芯片参数为: 3.3V供电 低电流为370uA典型值
- 效率较高的php下读取文本文件的代码
主要用下面这两个方法fread和 fgets的区别大家需要注意下 fread :以字节位计算长度,按照指定的长度和次数读取数据,遇到结尾或完成指定长度读取后停止. fgets :整行读取,遇 ...
- 【转】Java并发编程:synchronized
一.什么时候会出现线程安全问题? 在单线程中不会出现线程安全问题,而在多线程编程中,有可能会出现同时访问同一个资源的情况,这种资源可以是各种类型的资源:一个变量.一个对象.一个文件.一个数据库表等,而 ...
- hue报错StructuredException: timed out (code THRIFTSOCKET): None的处理
通过hue的web界面进行hive的sql查询,无法显示结果并报错timeout 报错如下:[28/Jul/2017 11:23:29 +0800] decorators ERROR error ru ...
- Python学习 --- 列表
list 函数可以将 序列变为列表 列表操作: 1 . 元素赋值, 根据索引,可以直接修改 2 . 删除元素, del x[i] 3 . 分片赋值, name[1:] = list (' '), 可以 ...
- Go语言环境安装&搭建(Linux)
Linux的东西果然不记不行啊~ 下载&安装 下载 我们先找到linux版的下载链接 https://golang.org/dl/ 打开网址找到Linux对应的链接右键复制下载地址 然后连接服 ...
- python-迭代器、生成器、内置函数及面向过程编程
一.迭代器 迭代器是迭代取值的工具,迭代是一个重复的过程,每一次重复都是基于上一次的结果而来的. 为什么要用迭代器呢? 1.可以不依赖索引取值 2.同一时刻在内存中只有一个值,不会过多的占用内存 如何 ...