首页 新闻 会员 周边

vscode中的launch.json出错

0
[待解决问题]
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++ Runner: Debug Session",
            "type": "cppdbg",
            "request": "launch",
            "args": [],
            "stopAtEntry": false,
            "externalConsole": true,
            "cwd": "${workspaceFolder}",
            // "program": "${fileDirname}/output/${fileBasenameNoExtension}.exe",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe/build/Debug/outDebug",
            "MIMode": "gdb",
            "miDebuggerPath": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

这就是我的launch.json代码,输出文件是放在一个叫output的文件夹当中的,求求哪一位大佬帮忙挑一挑

settings.json

{
  "C_Cpp_Runner.msvcBatchPath": "",
  "C_Cpp_Runner.cCompilerPath": "gcc",
  "C_Cpp_Runner.cppCompilerPath": "g++",
  "C_Cpp_Runner.debuggerPath": "gdb",
  "C_Cpp_Runner.cStandard": "",
  "C_Cpp_Runner.cppStandard": "",
  "C_Cpp_Runner.useMsvc": false,
  "C_Cpp_Runner.warnings": [
    "-Wall",
    "-Wextra",
    "-Wpedantic",
    "-Wshadow",
    "-Wformat=2",
    "-Wcast-align",
    "-Wconversion",
    "-Wsign-conversion",
    "-Wnull-dereference"
  ],
  "C_Cpp_Runner.msvcWarnings": [
    "/W4",
    "/permissive-",
    "/w14242",
    "/w14287",
    "/w14296",
    "/w14311",
    "/w14826",
    "/w44062",
    "/w44242",
    "/w14905",
    "/w14906",
    "/w14263",
    "/w44265",
    "/w14928"
  ],
  "C_Cpp_Runner.enableWarnings": true,
  "C_Cpp_Runner.warningsAsError": false,
  "C_Cpp_Runner.compilerArgs": [],
  "C_Cpp_Runner.linkerArgs": [],
  "C_Cpp_Runner.includePaths": [],
  "C_Cpp_Runner.includeSearch": [
    "*",
    "**/*"
  ],
  "C_Cpp_Runner.excludeSearch": [
    "**/build",
    "**/build/**",
    "**/.*",
    "**/.*/**",
    "**/.vscode",
    "**/.vscode/**"
  ],
  "C_Cpp_Runner.useAddressSanitizer": false,
  "C_Cpp_Runner.useUndefinedSanitizer": false,
  "C_Cpp_Runner.useLeakSanitizer": false,
  "C_Cpp_Runner.showCompilationTime": false,
  "C_Cpp_Runner.useLinkTimeOptimization": false,
  "C_Cpp_Runner.msvcSecureNoWarnings": false,
  "files.associations": {
    "iosfwd": "cpp"
  }
} 

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "windows-gcc-x64",
            "includePath": [
            "${workspaceFolder}/**"
            ],
            "compilerPath": "C:/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0/mingw64/bin/gcc.exe",
            "cStandard": "${default}",
            "cppStandard": "${default}",
            "intelliSenseMode": "windows-gcc-x64",
            "compilerArgs": [
                ""
            ]
        }
    ],
    "version": 4
}
mgcjade的主页 mgcjade | 菜鸟二级 | 园豆:202
提问于:2024-01-30 19:36
< >
分享
所有回答(2)
1

您提供的 launch.json 文件主要用于配置 VSCode 中 C/C++ 调试器的启动参数。您的配置看起来基本上是正确的,但可能有一些地方需要调整。

首先,确保以下几点:

确保输出文件路径正确:
在 launch.json 文件中,"program" 字段应该指向你要运行的可执行文件的路径。您在注释掉的一行中使用了 ${fileDirname}/output/${fileBasenameNoExtension}.exe,这是指向一个名为 "output" 的文件夹。请确保该文件夹存在,且其中包含正确的可执行文件。

json
Copy code
"program": "${fileDirname}/output/${fileBasenameNoExtension}.exe",
检查可执行文件路径:
如果您使用了 ${workspaceFolder}/${fileBasenameNoExtension}.exe/build/Debug/outDebug,确保该路径指向正确的可执行文件。根据您的描述,输出文件是放在一个名为 "output" 的文件夹中,因此应该与这个文件夹结构相匹配。

json
Copy code
"program": "${workspaceFolder}/${fileBasenameNoExtension}.exe/build/Debug/outDebug",
确保工作目录正确:
"cwd": "${workspaceFolder}" 表示当前工作目录是你的工作区根目录。这对于大多数情况来说是合适的,但确保它适用于您的项目。

json
Copy code
"cwd": "${workspaceFolder}",
在调试期间,您还可以尝试通过调整这些参数来定位问题。此外,确保在输出窗口和调试控制台中查看任何错误消息,以便更好地了解问题所在。

Technologyforgood | 园豆:5675 (大侠五级) | 2024-01-30 22:14
0

感觉这个配置不像是自己配置的吧,这个是copy过来的吧,建议这个配置先使用默认的,然后再手动配置其他参数,不然这么多配置很难快速确定具体的问题位置。还有确认gcc/g++/gdb等应用文件是否在系统环境中,并检查对应的vscode中的配置。

Angry_Panda | 园豆:420 (菜鸟二级) | 2024-01-31 09:57
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册