zoukankan      html  css  js  c++  java
  • Ubuntu如何使用Vscode写C++代码

     (一). 下载Vscode  

           (1). 打开Ubuntu软件

       

           (2). 搜索Vscode,下载并运行.

        

    (二). 安装C++

           (1). 看到右边的列表,点击最下面

                      

           (2). 然后我们搜索和下载 C++ 还有 C++ Intellisense(自动补全)

                  

    (三). 配置

           (1). 我们回到欢迎界面,然后选择一个目录(Open folder)

                

           (2). 我们创建一个cpp文件,并且命名为001.cpp

                 

         (3). 按下F5,然后选择C++ 

          (4). 这个时候会弹出launch.json

          (5). 我们修改这一句

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

        去掉 

    enter program name, for example  

         (6)把launch.json关闭,我们回到001.cpp.

           (7) 我们按下Ctrl + Shift + B ,然后会弹出,然后我们往下点,最后点Other

         (8) 然后在弹出的tasks.json中,我们修改command项.

    "command": "echo Hello"

    修改为:

    "command": "g++ -g -o a.out ${file}"

       (9) 然后我们就可以关闭 返回001.cpp了。

         (10)  我们按下 Ctrl + Shift + B 编译文件 然后再按下F5运行程序.

    最后附上完好的

    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": "${workspaceFolder}/a.out",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": true,
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }

    tasks.json

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "echo",
                "type": "shell",
                "command": "g++ -g -o a.out ${file}",
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }
  • 相关阅读:
    Windows Vista 桌面窗口管理器(1)
    Thinking in Java读书笔记――数组
    php图片上传存储源码,可实现预览
    php at(@)符号的用法简介
    Apache如何添加虚拟目录
    也发个PHP人民币金额数字转中文大写
    PHP Get Current URL
    Zend Studio下的PHP代码调试
    PHP url 加密解密函数
    使用新浪微博php SDK的一点记录
  • 原文地址:https://www.cnblogs.com/cgjh/p/10440633.html
Copyright © 2011-2022 走看看