zoukankan      html  css  js  c++  java
  • VSCode配置c++环境简单教程

    VSCode配置c++环境简单教程

    1.下载MinGW

    安装有关gdb,gcc,g++的所有包

    2.文件夹

    打开一个文件夹
    在里面随便写一个cpp
    不管是VS还是VSCode,它的基本操作单位都是文件夹(项目)

    3.配置launch.json

    位置
    这三个文件都在文件夹的.vscode中 如果MinGW被加载到path中就不需要第5步了

    {
    	"version": "0.2.0",
    	"configurations": [{
    		"name": "C++ Launch (GDB)", // 配置名称,将会在启动配置的下拉菜单中显示
    		"type": "cppdbg", // 配置类型,这里只能为cppdbg
    		"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
    		"launchOptionType": "Local", // 调试器启动类型,这里只能为Local
    		"targetArchitecture": "x86", // 生成目标架构,一般为x86或x64,可以为x86, arm, arm64, mips, x64, amd64, x86_64
    		"program": "${file}.exe", // 将要进行调试的程序的路径
    		"miDebuggerPath":"C:\MinGW\bin\gdb32.exe", // miDebugger的路径,注意这里要与MinGw的路径对应
    		//"args": [""], // 程序调试时传递给程序的命令行参数,一般设为空即可
    		"stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false
    		"cwd": "${workspaceRoot}", // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
    		"externalConsole": true, // 调试时是否显示控制台窗口,一般设置为true显示控制台
    		"preLaunchTask": "C:\MinGW\bin\g++.exe"   // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
    	}]
    }
    

    4.配置tacks.json

    忘了这个玩意是从哪里冒出来的啦
    反正随便一搞就冒出来啦

        {
        	"version": "0.1.0",
        	"command": "C:\MinGW\bin\g++.exe",
        	"args": ["-g","${file}","-o","${file}.exe"], // 编译命令参数
        	"problemMatcher": {
        		"owner": "cpp",
        		"fileLocation": ["relative", "${workspaceRoot}"],
        		"pattern": {
        			"regexp": "^(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
        			"file": 1,
        			"line": 2,
        			"column": 3,
        			"severity": 4,
        			"message": 5
        		}
        	}
        }
    

    5.配置c_cpp_properties.json文件

    {
    "configurations": [
    {
    "name": "Mac",
    "includePath": [
    "/usr/local/include",
    "${workspaceRoot}"
    ],
    "defines": [],
    "intelliSenseMode": "clang-x64",
    "browse": {
    "path": [
    "/usr/include",
    "/usr/local/include",
    "${workspaceRoot}"
    ],
    "limitSymbolsToIncludedHeaders": true,
    "databaseFilename": ""
    },
    "macFrameworkPath": [
    "/System/Library/Frameworks",
    "/Library/Frameworks"
    ]
    },
    {
    "name": "Linux",
    "includePath": [
    "/usr/include",
    "/usr/local/include",
    "${workspaceRoot}"
    ],
    "defines": [],
    "intelliSenseMode": "clang-x64",
    "browse": {
    "path": [
    "/usr/include",
    "/usr/local/include",
    "${workspaceRoot}"
    ],
    "limitSymbolsToIncludedHeaders": true,
    "databaseFilename": ""
    }
    },
    {
    "name": "Win32",
    "includePath": [
    "C:\MinGW\include",
    "C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++",
    "C:\MinGW\include\c++\3.4.5",
    "C:\MinGW\include\c++\3.4.5\mingw32",
    "C:\MinGW\lib\gcc\mingw32\6.3.0\include",
    "C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\tr1",
    "${workspaceRoot}"
    ],
    "defines": [
    "_DEBUG",
    "UNICODE"
    ],
    "intelliSenseMode": "msvc-x64",
    "browse": {
    "path": [
    "${workspaceRoot}"
    ],
    "limitSymbolsToIncludedHeaders": true,
    "databaseFilename": ""
    }
    }
    ],
    "version": 3
    }
    

    6.F5运行调试

    完事
    不过在调试控制台中输入gdb的命令需要加"-exec"
    例如"-exec list"

  • 相关阅读:
    软件测试(3)--coverage graph
    st_lab1
    数据结构与算法—单向链表
    数据结构与算法—顺序表
    Python的正则表达式(re包)
    Python的内置装饰器@property、@staticmethod、@classmethod
    Python的装饰器
    Python的生成器和迭代器
    Python变量的引用、拷贝和回收机制
    git常用命令总结
  • 原文地址:https://www.cnblogs.com/qdscwyy/p/7755951.html
Copyright © 2011-2022 走看看