【问题标题】:Error while debugging C++ in VS code using C++(windows) [closed]使用 C++(windows)在 VS 代码中调试 C++ 时出错 [关闭]
【发布时间】:2017-09-07 06:13:43
【问题描述】:

在 Windows 10 平台上使用 GCC 编译器使用 VS 代码调试 C++ 的人?我收到一些错误,例如某些 PDB 文件丢失或无法从 System32 目录打开。当我开始调试时,程序正在执行而不会遇到断点。那么我应该如何处理这些 PDB 错误,因为我无法对这些错误使用调试功能。

【问题讨论】:

  • 发生了什么事?
  • 我无法开始调试。你能告诉我在tasks.json和launch.json文件中要做的修改吗?

标签: c++ debugging visual-studio-code


【解决方案1】:

下面是我的 launch.json 和 task.json。 确保在您的项目文件夹中有一个 build 文件夹 启动.json

{
   "version": "0.2.0",
   "configurations": [
       {
           "name": "C++ Launch (GDB)",                
           "type": "cppdbg",                         
           "request": "launch",                        
           "targetArchitecture": "x86",                
           "program": "${workspaceRoot}\\build\\${fileBasename}.exe",                 
           "miDebuggerPath":"C:\\mingw-w64\\bin\\gdb.exe", 
           "args": [],     
           "stopAtEntry": false,                  
           "cwd": "${workspaceRoot}",                  
           "externalConsole": true,                  
           "preLaunchTask": "g++"                    
           }
   ]
}

tasks.json

{
   "version": "0.1.0",
   "command": "g++",
   "args": ["-g","-std=c++11","${file}","-o","${workspaceRoot}\\build\\${fileBasename}.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
       }
   }
}

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": "",
                "path": [
                    "/usr/include",
                    "${workspaceRoot}"
                ]
            },
            "intelliSenseMode": "clang-x64"
        },
        {
            "name": "Linux",
            "includePath": [
                "/usr/include"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": "",
                "path": [
                    "/usr/include",
                    "${workspaceRoot}"
                ]
            },
            "intelliSenseMode": "clang-x64"
        },
        {
            "name": "Win32",
            "includePath": [
                "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/include"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": "",
                "path": [
                    "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/include",
                    "${workspaceRoot}"
                ]
            },
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 2
}

文件夹

【讨论】:

  • 我应该创建一个名为 build 的新文件夹,然后将 launch.json 放入其中吗?
  • 你可以创建一个名为build的新文件夹,但不要将launch.json放在里面。launch.json和task.json你必须放在名为.vscode的文件夹中,我已经上传一张图片!
  • 启动调试过程,但出现此错误。
  • 无法打开 'istream.tcc':找不到文件 (\home\gfortran\gcc-home\workshop\gcc\objdir\x86_64-w64-mingw32\libstdc++-v3\include\bits\我
  • 确保“miDebuggerPath”正确。然后添加一个c_cpp_properties.json文件。编辑“includePath”
猜你喜欢
  • 2014-05-21
  • 1970-01-01
  • 2018-11-20
  • 1970-01-01
  • 2023-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多