个人vscode配置的各种环境

本文详细介绍了如何在VSCode中配置C/C++和Java的开发环境,包括设置launch.json和tasks.json文件,以实现代码的编译、运行和调试。对于C/C++,需配置g++.exe或gcc.exe;对于Java,则需指定mainClass。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

(1)c++/c运行环境配置

在工程文件夹下建立.vscode文件夹,在该文件夹下分别配置以下两个文件,如果是C语言,则把g++换成gcc,目录对应自己的目录

launch.json

{
    "version": "0.2.0",
    "configurations": [
     {
      "name": "g++.exe build and debug active file",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": true,  //修改此项,让其弹出终端
      "MIMode": "gdb",
      "miDebuggerPath": "D:\\mingw\\bin\\gdb.exe",
      "setupCommands": [
       {
        "description": "Enable pretty-printing for gdb",
        "text": "-enable-pretty-printing",
        "ignoreFailures": true
       }
      ],
      "preLaunchTask": "task g++" //修改此项
     }
    ]
   }

tasks.json

{
    "version": "2.0.0",
    "tasks": [
     {
      "type": "shell",
      "label": "task g++", //修改此项
      "command": "D:\\mingw\\bin\\g++.exe",
      "args": [
       "-g",
       "${file}",
       "-o",
       "${fileDirname}\\${fileBasenameNoExtension}.exe"
      ],
      "options": {
       "cwd": "D:\\mingw\\bin"
      },
      "problemMatcher": [
       "$gcc"
      ],
      "group": "build"
     }
    ]
   }

(2)java的配置

launch.json

{
    
        "version": "0.2.0",
        "configurations": [
            {
                "type": "java",
                "name": "Debug (Launch)",
                "request": "launch",
                "mainClass": "Main"
            },      
        ]
    
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值