一、Jetson 安装Visual Studio Code配置C\C++环境
1.安装Vs Code由于Jetson Nano arm64结构,导致市面上主流的IDE并不能适配在网上看过很多资料之后,终于找到使用VsCode作为IDE在Jetson nano上的安装方式,现将其安装包分享至百度网盘,很贴心吧链接:https://pan.baidu.com/s/1h-gCI0NLYXXBN5ZMAMdJOw提取码:ciaz下载至目录文件夹后,运行以下命令:sudo dpkg
1.安装Vs Code
1.1 Code oss和 Code区别
- Code-OSS:是一个没有任何专利性代码的开源项目。
- Visual Studio Code:是在传统微软产品许可下发布的
带有微软特定定制的
Code - OSS存储库的发行版。
1.2 安装
由于Jetson Nano arm64结构,导致市面上主流的IDE并不能适配
在网上看过很多资料之后,终于找到使用VsCode作为IDE在Jetson nano上的安装方式,现将其安装包分享至百度网盘,很贴心吧
链接:https://pan.baidu.com/s/1h-gCI0NLYXXBN5ZMAMdJOw
提取码:ciaz
下载至目录文件夹后,运行以下命令:
sudo dpkg -i code-oss_1.32.0-1550644676_arm64.deb
安装完成后,以后只需要在终端中输入
code oss 即可运行 VsCode
1.3 补充
- dpkg:用来安装.deb文件时,不会解决模块的依赖关系,且不会关心ubuntu的软件仓库内的软件,可以用于安装本地的deb文件。
- apt-get:会解决和安装模块的依赖问题,并会咨询软件仓库,但不会安装本地的deb文件,apt-get是建立在dpkg之上的软件管理工具。
1.70以上的版本在Jetson ubuntu20.04中无法打开。
历史版本Visual Studio Code下载地址:
https://update.code.visualstudio.com/{version}/linux-deb-arm64/stable
Substitute the specific release you want in the {version} placeholder. For example, to download the Linux Arm32 debian version for 1.50.1, you would use
https://update.code.visualstudio.com/1.50.1/linux-deb-arm64/stable
You can use the version string latest, if you’d like to always download the latest VS Code stable version.
sudo apt install ./vscode-linux-deb.arm64.deb #安装(apt会解决和安装模块的依赖问题)
2.配置C\C++环境
code . #打开vscode
终端输入code.打开vscode,按照C/C++插件。在工程目录下创建 .vscode目录,同时在目录创建一下三个文件。
- tasks.json(编译选项设置)
- launch.json(Debug设置)
- c_cpp_properties.json(头文件路径设置)
2.1 tasks.json文件
(1)选择Terminal > Configure Default Build Task。
(2)选择Gcc
(3)选择Terminal > Run Build Task编译源码
/*gcc编译设置*/
{链接
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc", /*使用Gcc命令编译*/
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-pthread",
"-I/usr/include/gstreamer-1.0",
"-I/usr/include/glib-2.0",
"-I/usr/lib/aarch64-linux-gnu/glib-2.0/include",
"-lgstreamer-1.0",
"-lgobject-2.0",
"-lglib-2.0"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true /*Ctrl+Shift+B快捷键是否启用*/
},
"detail": "compiler: /usr/bin/gcc"
}
]
}
2.2 launch.json文件
(1)Run > Add Configuration…
(2)选择C++ (GDB/LLDB)
(3)选择g++ build and debug active file
"version": "0.2.0",
"configurations": [
{
"name": "gcc - Build and debug active file",/*配置名称,将会在启动配置的下拉菜单中显示*/
"type": "cppdbg",/*配置类型,这里只能为cppdbg*/
"request": "launch",/*请求配置类型,可以为launch或attach*/
/* ${fileDirname} - 当前项目的目录
* ${fileBasenameNoExtension} - 当前程序去掉后缀名字
*/
"program": "${fileDirname}/${fileBasenameNoExtension}",/*要进行调试程序的名字*/
"args": [],
"stopAtEntry": false,/*设为true时程序将暂停在程序入口处,我一般设置为true*/
"cwd": "${fileDirname}",/*调试程序时的工作目录*/
"environment": [],
"externalConsole": false,/*调试时是否显示控制台窗口,一般设置为true显示控制台*/
"MIMode": "gdb",/*指定连接的调试器*/
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc build active file",/*调试会话开始前执行的任务,与tasks.json的label相对应*/
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
调试过程出现的问题
错误是因为缺少glibc库造成的,因此打开终端下载相应文件
sudo mkdir -p /build/glibc-D9JkfM
cd /build/glibc-D9JkfM
sudo wget https://ftp.gnu.org/gnu/libc/glibc-2.27.tar.gz
sudo tar -zxvf glibc-2.27.tar.gz
2.3 c_cpp_properties.json文件
快捷键Ctrl+Shift+P
相关链接
1.json文件中变量链接
2.VsCode官方指导手册
3.VsCode官网下载链接
更多推荐
所有评论(0)