VScode:进程无法访问该文件,因为第1行的另一个进程正在使用该文件 我试图在VSCode建立C++环境, 当我试图运行helloworld文件时,我遇到了这个错误

VScode:进程无法访问该文件,因为第1行的另一个进程正在使用该文件 我试图在VSCode建立C++环境, 当我试图运行helloworld文件时,我遇到了这个错误,c++,windows,visual-studio-code,mingw32,file-not-found,C++,Windows,Visual Studio Code,Mingw32,File Not Found,程序“helloworld.exe”无法运行:进程无法访问该文件 因为第1行的另一个进程正在使用它 my tasks.json: { "version" : "2.0.0", "tasks" :[ { "type" : "cppbuild",

程序“helloworld.exe”无法运行:进程无法访问该文件 因为第1行的另一个进程正在使用它

my tasks.json:

{
    "version" : "2.0.0",
                "tasks" :[
                    {
                      "type" : "cppbuild",
                      "label" : "echo",
                      "command" : "C:\\MinGW\\bin\\cpp.exe",
                      "args" : [
                          "-g ",

                          "-o",
                          "${workspaceFolder}\\helloworld.exe",

                      ],
                      "options" : {
                          "cwd" : "${workspaceFolder}"
                      },
                      "problemMatcher" : ["$gcc"],
                      "group" : {

                          "kind" : "build",
                          "isDefault" : true
                      },
                      "detail" : "compiler: C:\\MinGW\\bin\\cpp.exe"

                    }
                ]
}

当我试着调试我的程序时,得到一个错误,说“没有这样的文件或目录”

正在执行的任务:g++-g helloworld.cpp g++.exe:错误:helloworld.cpp:没有这样的文件或目录 g++.exe:致命错误:没有输入文件 编译终止。 终端进程“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe-命令g++-g helloworld.cpp”终止,退出代码为:1

My launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/helloworld.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "echo"
        }
    ]
}    
请帮助我摆脱这个错误,并帮助我运行我的第一个C++程序在VSCODE上:(< /P>)
谢谢。

您的第一个错误可能意味着您最后一次执行的
helloworld.exe
仍在运行,或者您的防病毒程序已打开。您的第二个错误似乎是helloworld.cpp不在
${workspaceFolder}的任何文件夹中
@drescherjm.Yeah,非常感谢您的友好回复。您能为我建议一些方法来消除此错误吗:)。看起来您的tasks.json缺少源文件。如果您只有一个源文件,或者您只想构建活动文件,或者如果您不想构建活动文件,则应在
“${file}”之后添加
”${workspaceFolder}\\\\*.cpp“。文档在此处解释了tasks.json文件: