内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Ubuntu下怎么安裝并配置VSCode編譯C++

這篇文章主要介紹“Ubuntu下怎么安裝并配置VS Code編譯C++”的相關(guān)知識(shí),小編通過(guò)實(shí)際案例向大家展示操作過(guò)程,操作方法簡(jiǎn)單快捷,實(shí)用性強(qiáng),希望這篇“Ubuntu下怎么安裝并配置VS Code編譯C++”文章能幫助大家解決問(wèn)題。

創(chuàng)新互聯(lián)公司提供高防服務(wù)器、云服務(wù)器、香港服務(wù)器、德陽(yáng)服務(wù)器托管

ubuntu下安裝并配置vs code編譯c++

安裝vs code

sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
sudo apt-get update
sudo apt-get install ubuntu-make
sudo umake web visual-studio-code

然后按a直接默認(rèn)同意就可以。

安裝插件

打開(kāi)vs code后,按crtl + shift + p調(diào)出命令行,然后搜索c++,安裝微軟自己開(kāi)發(fā)的那個(gè)。

同樣可以安裝c++ intellisense插件,用于自動(dòng)補(bǔ)全代碼。

配置launch.json和tasks.json

注意vs code只能打開(kāi)源碼所在的文件夾,而不是直接打開(kāi)源碼文件,否則下面將無(wú)法進(jìn)行!

打開(kāi)源碼所在文件夾后,在該文件夾中打開(kāi)源碼。按f5鍵,選擇c++,

Ubuntu下怎么安裝并配置VS Code編譯C++

然后會(huì)自動(dòng)生成launch.json文件,下面只需要修改兩個(gè)地方

"program": "enter program name, for example \${workspaceroot}/a.out",

改為

"program": "${workspaceroot}/a.out",

"cwd": "\${workspaceroot}",

改為

"cwd": "${workspaceroot}",

完整的launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "(gdb) launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceroot}/a.out",
      "args": [],
      "stopatentry": false,
      "cwd": "${workspaceroot}",
      "environment": [],
      "externalconsole": true,
      "mimode": "gdb",
      "setupcommands": [
        {
          "description": "enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignorefailures": true
        }
      ]
    }
  ]
}

然后,調(diào)出命令行,輸入task runner,選擇others

Ubuntu下怎么安裝并配置VS Code編譯C++ 

此時(shí)將自動(dòng)生成tasks.json

將其中的

"command": "echo",

改為

"command": "g++",

"args": ["hello world"],

改為

"args": ["-g","${workspaceroot}/main.cpp"],

注意這里的main.cpp要和你當(dāng)前路徑的源碼名稱一致。

完整的tasks.json

{
  // see https://go.microsoft.com/fwlink/?linkid=733558
  // for the documentation about the tasks.json format
  "version": "0.1.0",
  "command": "g++",
  "isshellcommand": true,
  "args": ["-g","${workspaceroot}/main.cpp"],
  "showoutput": "always"
}

運(yùn)行測(cè)試

隨便編寫(xiě)個(gè)代碼

#include<iostream>
using namespace std;

int main()
{
  cout<<"hello vs code"<<endl;
  return 0;
}

按crtl + shift + b構(gòu)建,按f5運(yùn)行,發(fā)現(xiàn)終端一閃而過(guò),什么都沒(méi)有輸出。于是考慮windows下的辦法。

#include<iostream>
#include<stdlib.h>
using namespace std;

int main()
{
  cout<<"hello vs code"<<endl;
  system("pause");
  return 0;
}

同樣并沒(méi)有卵用。那就換一種方式。

#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
  cout<<"hello vs code"<<endl;
  getchar();
  return 0;
}

按crtl + shift + b構(gòu)建,按f5運(yùn)行,程序完美輸出。有圖為證,哈哈

Ubuntu下怎么安裝并配置VS Code編譯C++

后記:

期間在終端里執(zhí)行了以下操作

sudo apt-get install clang

如果提示clang有錯(cuò)可以運(yùn)行該命令,安裝clang。

關(guān)于“Ubuntu下怎么安裝并配置VS Code編譯C++”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,小編每天都會(huì)為大家更新不同的知識(shí)點(diǎn)。

標(biāo)題名稱:Ubuntu下怎么安裝并配置VSCode編譯C++
分享路徑:http://www.rwnh.cn/article30/jiecpo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、云服務(wù)器、全網(wǎng)營(yíng)銷推廣Google、商城網(wǎng)站App開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站
崇义县| 南投县| 平定县| 枣庄市| 花莲市| 贡山| 林周县| 湖口县| 南宫市| 磐石市| 临湘市| 辽中县| 安康市| 延吉市| 潮安县| 虎林市| 延津县| 武汉市| 肥乡县| 沈丘县| 饶平县| 明溪县| 漳州市| 南投县| 宿松县| 诏安县| 弋阳县| 太白县| 南昌县| 新平| 龙门县| 馆陶县| 上杭县| 扶沟县| 明星| 遂川县| 印江| 定边县| 永州市| 叶城县| 南陵县|