1.下载Visual Studio Code 编译器

可以去Ubuntu自带的应用商店下载,或者使用你命令行下载

2.设置中文显示

直接下载的是英文版本,需要设置成中文显示

  1. 先去VS Code自带的商店下载的插件,快捷键:Ctrl+Shift+x,搜索Chinese (Simplified) Language Pack for Visual Studio Code,点击下载;
  2. 然后配置语言,快捷键:Ctrl+Shift+p,在选框中输入configure display language,点击确定,在出现的locale.json文件中,将"locale":“en” 改为“locale”:“zh-CN”;
  3. 重启VSCode;

3.下载构建CMake工程的各种依赖包

和第二步类似去VS Code自带的商店下载的插件,快捷键:Ctrl+Shift+x,下载各种依赖包,包括:c/c++,c/c++ clang command adapter,c++ intellisense,CMake和CMake Tools如下图所示:

4.各种json文件配置

打开一个含有CMakeLists.txt的完整的Cmake工程的文件夹
在.vscode要建立三个json文件才能对Cmake工程进行编译和调试,分别是c_cpp_properties.json,launch.json和tasks.json

  1. c_cpp_properties.json的配置如下
{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**","/usr/include","/usr/local/include","/usr/local/cuda/include"],"defines": [],"compilerPath": "/usr/bin/gcc","cStandard": "c11","cppStandard": "c++17","intelliSenseMode": "clang-x64","compileCommands": "${workspaceFolder}/build/compile_commands.json"}],"version": 4
}
  1. launch.json配置如下
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "(gdb) Launch","type": "cppdbg","request": "launch","program": "${workspaceFolder}/build/eigenMatrix",// 表示可执行程序所在的路径,其中,${workspaceRoot}表示VScode加载的文件夹的根目录"args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": true,"MIMode": "gdb","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}],"preLaunchTask": "make build"###最好删了,不然会影响调试,每次调试都直接执行make build}]
}
  1. tasks.json是编译任务的文件,配置如下
{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "make build",//编译的项目名,build"type": "shell","command": "cd ./build ;cmake ../ ;make",//编译命令"group": {"kind": "build","isDefault": true}},{"label": "clean","type": "shell","command": "make clean",}]
}

5.配置自己的Cmake工程

  1. CMakeLists.txt如下:
cmake_minimum_required( VERSION 2.8 )
project( geometry )# 添加Eigen头文件
include_directories( "/usr/include/eigen3" )add_executable( eigenGeometry eigenGeometry.cpp )
  1. eigenGeometry.cpp如下:
#include <iostream>
#include <cmath>
using namespace std;#include <Eigen/Core>
// Eigen 几何模块
#include <Eigen/Geometry>/****************************
* 本程序演示了 Eigen 几何模块的使用方法
****************************/int main ( int argc, char** argv )
{// Eigen/Geometry 模块提供了各种旋转和平移的表示// 3D 旋转矩阵直接使用 Matrix3d 或 Matrix3fEigen::Matrix3d rotation_matrix = Eigen::Matrix3d::Identity();// 旋转向量使用 AngleAxis, 它底层不直接是Matrix,但运算可以当作矩阵(因为重载了运算符)Eigen::AngleAxisd rotation_vector ( M_PI/4, Eigen::Vector3d ( 0,0,1 ) );     //沿 Z 轴旋转 45 度cout .precision(3);cout<<"rotation matrix =\n"<<rotation_vector.matrix() <<endl;                //用matrix()转换成矩阵// 也可以直接赋值rotation_matrix = rotation_vector.toRotationMatrix();// 用 AngleAxis 可以进行坐标变换Eigen::Vector3d v ( 1,0,0 );Eigen::Vector3d v_rotated = rotation_vector * v;cout<<"(1,0,0) after rotation = "<<v_rotated.transpose()<<endl;// 或者用旋转矩阵v_rotated = rotation_matrix * v;cout<<"(1,0,0) after rotation = "<<v_rotated.transpose()<<endl;// 欧拉角: 可以将旋转矩阵直接转换成欧拉角Eigen::Vector3d euler_angles = rotation_matrix.eulerAngles ( 2,1,0 ); // ZYX顺序,即roll pitch yaw顺序cout<<"yaw pitch roll = "<<euler_angles.transpose()<<endl;// 欧氏变换矩阵使用 Eigen::IsometryEigen::Isometry3d T=Eigen::Isometry3d::Identity();                // 虽然称为3d,实质上是4*4的矩阵T.rotate ( rotation_vector );                                     // 按照rotation_vector进行旋转T.pretranslate ( Eigen::Vector3d ( 1,3,4 ) );                     // 把平移向量设成(1,3,4)cout << "Transform matrix = \n" << T.matrix() <<endl;// 用变换矩阵进行坐标变换Eigen::Vector3d v_transformed = T*v;                              // 相当于R*v+tcout<<"v tranformed = "<<v_transformed.transpose()<<endl;// 对于仿射和射影变换,使用 Eigen::Affine3d 和 Eigen::Projective3d 即可,略// 四元数// 可以直接把AngleAxis赋值给四元数,反之亦然Eigen::Quaterniond q = Eigen::Quaterniond ( rotation_vector );cout<<"quaternion = \n"<<q.coeffs() <<endl;   // 请注意coeffs的顺序是(x,y,z,w),w为实部,前三者为虚部// 也可以把旋转矩阵赋给它q = Eigen::Quaterniond ( rotation_matrix );cout<<"quaternion = \n"<<q.coeffs() <<endl;// 使用四元数旋转一个向量,使用重载的乘法即可v_rotated = q*v; // 注意数学上是qvq^{-1}cout<<"(1,0,0) after rotation = "<<v_rotated.transpose()<<endl;return 0;
}
  1. ctrl+shift+B运行代码,成功如下所示:

Ubuntu下使用VS Code构建CMake工程相关推荐

  1. ubuntu下常用服务器的构建

    1 ftp 1.1 ftp服务器 1.安装vsftpd服务器 sudo apt-get install vsftpd 2.配置vsftpd.conf文件 sudo vi /etc/vsftpd.con ...

  2. Ubuntu下配置VS Code C++ 环境

    参考: https://www.cnblogs.com/foxer-z/p/12520904.html https://segmentfault.com/a/1190000020155987 VS C ...

  3. Ubuntu下安装VS Code遇到的小问题

    Ubuntu安装步骤 桌面打开终端输入 sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make sudo apt-get update sudo ...

  4. Windows下使用VS Code编译和构建LoRaWan开源节点代码

    Windows下使用VS Code编译和构建LoRaWan开源节点代码 1.下载LoRaWan节点端开源代码 2.构建LoRaMac-node的先决条件 2.1添加环境变量 3.使用VS Code构建 ...

  5. vscode在ubuntu下安装插件,同时配置python虚拟环境、ctrl+鼠标滚轮放大代码窗口设置

    linux下vs code 两大问题: 1.无法在code中切换虚拟环境 2.文件夹有时候会莫名其妙打不开,似乎和文件夹的命名有关系. 已弃坑,不再使用. ---------------------- ...

  6. Hi3516DV300 Cmake工程建立教程

    Hi3516DV300 Cmake工程建立教程 一.准备事项 二.建立基本的Cmake工程 三.提取SDK完善Cmake工程 四.编译与调试 五.总结 一.准备事项 1.以默认路径安装交叉编译器arm ...

  7. 【ubuntu(Linux)安装Vs code并配置c++编译及cmake多文件编译】

    目录标题 VS code配置c++编译环境 1. Linux系统安装 2. 在Ubuntu中安装VS code 2.1. 首先下载对应系统的VS code安装包 2.2. 安装VS code 3. 在 ...

  8. 在Ubuntu下构建Bullet以及执行Bullet的样例程序

    在Ubuntu下构建Bullet以及执行Bullet的样例程序 1.找到Bullet的下载页,地址是:https://code.google.com/p/bullet/downloads/list 2 ...

  9. 在Ubuntu下构建Bullet以及运行Bullet的例子程序

    在Ubuntu下构建Bullet以及运行Bullet的例子程序 1.找到Bullet的下载页,地址是:https://code.google.com/p/bullet/downloads/list 2 ...

最新文章

  1. 迟到4个月的华为P50,没有5G只有4G,售价4488元起
  2. Spring源码解析-三级缓存与循环依赖,nginx架构图
  3. 怎么通过邮箱发超大附件?介绍一种基于云服务的方法
  4. cnn stride and padding_Tensorflow学习笔记- 模型建立与训练篇(CNN)
  5. dup和dup2详解
  6. oracle通过数据泵导出数据,Oracle通过PL/SQL数据泵导出导入数据的命令
  7. 如何在 FineUIMvc 中引用第三方 JavaScript 库
  8. 前端:【学成在线项目】HTML+CSS详细制作过程(代码只做参考)
  9. Android学习笔记之百度地图基础知识
  10. win7 去掉快捷方式小箭头
  11. Apache commons-exec的使用
  12. Python爬虫-bug处理办法(持续更新)
  13. http://www.cnblogs.com/xinxin-csharp/p/6146770.html
  14. 图片加密(一)颜色加密
  15. C、C++、java的区别
  16. android 字符串转小数点,Android实现计算器(计算表达式/计算小数点以及括号)...
  17. d3.js画柱状图超详细教程
  18. 《零基础入门学习Python》读书笔记
  19. 软件测试的软件资源,软件测试都会都用到哪些工具?
  20. 作为程序员的他凭什么成就年薪100W架构师?

热门文章

  1. Kafka (阿里云 ECS)磁盘类故障修复操作文档
  2. python3 从入门到精通视频教程下载-Python 3.7从入门到精通(视频教学版)
  3. dp的定义原理和dpi,ppi,px,sp之间的区别
  4. 轮播图制作,详细步骤及 HTML+CSS+JS 完整代码
  5. r语言重复向量变矩阵_游戏如何使重复变得有趣
  6. bootstrap方法
  7. PAT乙级——1005
  8. 【计算机图形学】c++ OpenGL Sutherlang-Hodgman 多边形裁剪
  9. 元宇宙电商——非同质化商品的新模式
  10. 如何做好每天的计划?