首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >dbg无法在带有WSL2的VScode上工作-无法解析不存在的文件'vscode-remote://wsl+ubuntu-20.04..‘

dbg无法在带有WSL2的VScode上工作-无法解析不存在的文件'vscode-remote://wsl+ubuntu-20.04..‘
EN

Stack Overflow用户
提问于 2020-08-14 21:59:41
回答 1查看 2.2K关注 0票数 4

我已经安装了WSL2和构建工具,一切都在linux控制台上运行良好(包括我能够用dbg调试的一个测试c++程序)。通过安装VSCode和一些扩展(c/c++和Remote WSL),我现在正在尝试在我的windows10机器上有一个工作的开发环境。

Build运行得很好,但是当我尝试调试时,在执行(F10)几行之后,我得到了错误:

代码语言:javascript
复制
Unable to open 'libc-start.c': Unable to read file 'vscode-remote://wsl+ubuntu-20.04/build/glibc-YYA7BZ/glibc-2.31/csu/libc-start.c' (Error: Unable to resolve non-existing file 'vscode-remote://wsl+ubuntu-20.04/build/glibc-YYA7BZ/glibc-2.31/csu/libc-start.c').

从那时起,调试器基本上不再工作,每次我按下F10 (或F11)时,我都会得到一个新的弹出窗口,并显示相同的错误

screenshot of error and dev environment

按下"Create File“按钮会出现"Unable to write file 'vscode-remote://wsl+ubuntu-20.04....”(同上文件)。

下面是我的launch.json文件

代码语言:javascript
复制
    {
    // 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": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

和我的tasks.json:

代码语言:javascript
复制
{
// See https://go.microsoft.com/fwlink/?LinkId=733558 
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "type": "shell",
        "label": "C++ Compile",
        "command": "/usr/bin/g++",
        "args": ["-g","*.cpp","-o","${fileDirname}/${fileBasenameNoExtension}"],
        "options": {"cwd": "${workspaceFolder}"},
        "problemMatcher": ["$gcc"],
        "group": {"kind": "build","isDefault": true}
    }
]

}

在发帖之前,我已经搜索了很多。其他人在老帖子中也有类似的问题,但他们中的大多数人声称这是一个旧的bug,他们说这个问题已经通过升级解决了。我正在运行我正在使用的所有东西的最新版本(包括VSCode和插件)。

提前感谢所有帮助我们的人。

EN

回答 1

Stack Overflow用户

发布于 2021-04-17 05:04:46

添加

代码语言:javascript
复制
"sourceFileMap": { "//wsl$/Ubuntu-20.04" : "/" }

launch.json帮我解决了这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63414248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档