久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      配置詳解:vscode中遠(yuǎn)程調(diào)試c++

      配置詳解:vscode中遠(yuǎn)程調(diào)試c++

      php入門(mén)到就業(yè)線上直播課:進(jìn)入學(xué)習(xí)
      Apipost = Postman + Swagger + Mock + Jmeter 超好用的API調(diào)試工具:點(diǎn)擊使用

      最近在學(xué)習(xí)linux webserver開(kāi)發(fā),需要在linux下調(diào)試自己的C/C++代碼,但是linux下不像在windows下,直接Visio Studio或者其它集成開(kāi)發(fā)環(huán)境那么方便,現(xiàn)在的linux下開(kāi)發(fā),比較麻煩。于是可以考慮使用VScode遠(yuǎn)程開(kāi)發(fā)。但是網(wǎng)上的很多教程都不是很清晰,這里在嘗試了很多教程后,踩了不少坑,最后總結(jié)如下?!就扑]學(xué)習(xí):《vscode入門(mén)教程》】

      1.系統(tǒng)配置

      遠(yuǎn)程系統(tǒng):ubuntu18.04(虛擬機(jī))
      開(kāi)發(fā)主機(jī):windows10

      2.ubuntu遠(yuǎn)程端安裝軟件和設(shè)置

      (1)安裝必要軟件:ssh(系統(tǒng)通信),gdb,gsdbserver(代碼調(diào)試):

      sudo apt-get install openssh-server sudo apt-get install gdb sudo apt-get install gdbserver
      登錄后復(fù)制

      (2)創(chuàng)建測(cè)試文件夾和文件

      注意:

      • 雖然你可能想一步到位,直接拿自己最后的程序測(cè)試,但是這里不建議這么做,建議先新建一個(gè)hello,world程序測(cè)試,成功后再調(diào)試自己的代碼。
      • 文件夾位置和內(nèi)容無(wú)所謂,但是最好簡(jiǎn)單一些

      cd ~/桌面 mkdir testvs cd testvs touch main.cpp gedit main.cpp
      登錄后復(fù)制

      其中main.cpp代碼為:

      #include <stdio.h>   int main() {     int a = 1;     printf("hello worldn");     getchar();     return 0; }
      登錄后復(fù)制

      (3)編譯,得到可執(zhí)行文件

      g++ main.cpp -o main -g
      注意:

      • 加-g選項(xiàng),不然沒(méi)法用gdb調(diào)試
      • 運(yùn)行后testvs文件夾下有main.cpp和main兩個(gè)文件

      (4)啟動(dòng)gdbserver

      (4.1)首先看一下自己的ubuntu系統(tǒng)ip地址:

      hostname -I
      配置詳解:vscode中遠(yuǎn)程調(diào)試c++
      可以得到本地ip地址為192.168.199.131

      (4.2)啟動(dòng)gdbserver(注意更改ip地址和測(cè)試文件目錄)

      gdbserver 192.168.199.131:2000 ~/桌面/testvs/main
      配置詳解:vscode中遠(yuǎn)程調(diào)試c++

      3.主機(jī)VScode設(shè)置

      (1)首先在VScode中安裝下面幾個(gè)插件:

      • C/C++
      • C/C++ Extension Pack
      • Remote – SSH
      • Remote Development

      (2)ssh遠(yuǎn)程連接

      左下角“管理”->"控制面板",之后找到選項(xiàng)“Remote-SSH:Connect to Host…” -> Add New SSH Host…
      輸入ubuntu系統(tǒng)ip地址,出來(lái)新界面

      配置詳解:vscode中遠(yuǎn)程調(diào)試c++
      紅框內(nèi)輸入ubuntu系統(tǒng)密碼,左下角顯示綠色ip地址即連接成功,如下圖。

      配置詳解:vscode中遠(yuǎn)程調(diào)試c++

      (3)打開(kāi)測(cè)試文件

      打開(kāi)文件夾 -> 選擇測(cè)試文件夾目錄,點(diǎn)“確定”按鈕

      配置詳解:vscode中遠(yuǎn)程調(diào)試c++
      選中C/C++擴(kuò)展,“在SSH:XXX中安裝”。C/C++ Extension Pack擴(kuò)展同理
      然后重啟Vscode和Ubuntu中的gdbserver(一定得要重啟,否則接下來(lái)的步驟會(huì)報(bào)錯(cuò))重新執(zhí)行上述遠(yuǎn)程連接流程。

      (4)設(shè)置配置文件

      (4.1)配置tasks.json

      從菜單欄選擇Terminal>Configure Default Build Task, 在下拉欄里選擇C/C++: g++ build active file. 之后生成tasks.json文件,將內(nèi)容更換為:

      {     // 有關(guān) tasks.json 格式的文檔,請(qǐng)參見(jiàn)      // https://go.microsoft.com/fwlink/?LinkId=733558      "version": "2.0.0",      "tasks": [      {      "type": "shell",      "label": "g++ build active file",      "command": "/usr/bin/g++",      "args": [      "-std=c++11",      "-g",      "${file}",      "-o",      "${fileDirname}/${fileBasenameNoExtension}"      ],      "options": {      "cwd": "/usr/bin"      },      "problemMatcher": [      "$gcc"      ],      "group": {      "kind": "build",      "isDefault": true      }      },      { //刪除二進(jìn)制文件      "type": "shell",      "label": "delete output file",      "command": "rm",      "args": [      "${fileDirname}/${fileBasenameNoExtension}"      ],      "presentation": {      "reveal": "silent", //刪除過(guò)程不切換終端(專注程序輸出)      }      }      ]     }
      登錄后復(fù)制

      (4.2)配置launch.json

      在菜單欄選擇Debug>Add Configuration, 選擇C++ (GDB/LLDB), 在下拉欄中選擇g++ build and debug active file.生成launch.json,內(nèi)容更改為:

      {     // 使用 IntelliSense 了解相關(guān)屬性。      // 懸停以查看現(xiàn)有屬性的描述。     // 欲了解

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)