目录
1.2安装remote-SSH和remote development插件。
这是用visual studio code远程编辑和调试linux代码的教程,使用visual studio远程编辑和调试linux代码的教程见:使用visual studio 远程编辑和调试linux代码
1.配置vscode远程开发和阅读代码
1.1首先安装vscode,步骤省略。
1.2安装remote-SSH和remote development插件。
在vscode的软件扩展里面搜索remote ssh可以找到该插件,点击安装即可。
用同样的方法安装remote development。
1.3配置ssh
按F1,然后选择connect to host
然后选择configure SSH Host
然后将服务器的IP地址和用户名加上,如下图所示
然后再次按F1,选择IP地址则连接到相应的服务器。
然后就可以打开你想要的文件夹进行开发了。 这时候file----open folder就可以直接打开远程服务器的文件夹了。
2.配置远程调试
2.1在服务器安装ssh server
yum install openssh-server #centos
apt-get install openssh-server #ubuntu
2.2在服务器安装gdb
yum install gdb #centos
apt-get install gdb #ubuntu
2.3在服务器安装gdbserver
yum install gdb-gdbserver #centos
apt-get install gdbserver #ubuntu
2.4修改launch.json
在vscode的菜单栏选择 run--Add Configuration---C++(GDB/LLDB),会生成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": "enter program name, for example ${workspaceFolder}/a.out",
"args": [
"--input_url", "/home/chw/CNStream/data/videos/cars.mp4"
"--model_path", "/home/chw/CNStream/data/models/yolov3_b4c4_argb_mlu270.cambricon"
"--label_path", "/home/chw/CNStream/data/models/label_map_coco.txt"
"--keep_aspect_ratio", "true"
"--model_input_pixel_format", "ARGB"
"--how_to_show", "video"
"--dev_id", "0"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb" ,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
然后把program那里的可执行程序的名字修改一下,比如"program": " ${workspaceFolder}/ise",
如果想加参数就在args那里写上参数,要用双引号括起来
如果想要设置环境变量,那么可以把"text": "-enable-pretty-printing", 修改成"text": "set env LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
",
"cwd"::这个参数的作用是设置当前工作目录,比如你代码中用了./model/pcb.te2,那么这里的相对路径就是相对于工作路径的(不是相对于可执行程序的路径,在命令行执行程序的时候是相对于可执行程序的路径),这个cwd不设置默认就是打开文件夹路径。
2.5编译自己的可执行程序,
编译时记得加-g,要不然没法调试,比如打了断点发现根本没用。
2.6调试
clion远程调试的时候要先在服务器端执行gdbserver :port ./可执行程序名字,然后才能在clion调试。
vscode不需要在服务器端执行什么,直接在vscode上F5就可以调试了。