Mac上安装vscode以及可能出现的问题

1.软件下载

2.插件安装

实现 C/Cpp 代码自动补全,函数跳转。

打开VScode后,按下组合键“⇧⌘X”,打开扩展,输入“C/C++”,安装“C/C++”、“C/C++ Clang Command Adapter”,安装完成后,重启VScode让插件生效。

3.配置启动环境

调试–>创建C++(GDB/LLDB)–>产生launch.json文件并修改如下:

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb"
        },

        {
            "type": "node",
            "request": "launch",
            "name": "启动程序",
            "program": "${file}"
        }
    ]
}

4.配置编译环境

按下组合键“⇧⌘B”,如下图操作
在这里插入图片描述

生成“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++",
           "args":[
               "haha.c"
           ],
           "group": {
               "kind": "build",
               "isDefault": true
           }
       }
   ]
}

其中"args"参数为主函数所在的文件,我上面的是"haha.c"。

5.运行

使用组合键“⇧⌘B”编译,“fn+F5”进行运行,如果不报错,就可以在命令行查看a.out的输出的内容。

出现的问题

1.编译的时候找不到a.out文件

自己创建一个

发布了205 篇原创文章 · 获赞 655 · 访问量 53万+

猜你喜欢

转载自blog.csdn.net/qq_33414271/article/details/102320305