vs code 运行 c 语言 task 提示系统找不到指定的路径

2019-04-21 11:24:49 +08:00
 jht
  1. 出现的问题见标题

  2. launch.json:

    {
        // 使用 IntelliSense 了解相关属性。 
        // 悬停以查看现有属性的描述。
        // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${workspaceRoot}/${fileBasenameNoExtension}.exe",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": true,
                "preLaunchTask": "gcc",
                "MIMode": "gdb",
                "miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }
    
  3. task.json:

    {
    // 有关 tasks.json 格式的文档,请参见
        // https://go.microsoft.com/fwlink/?LinkId=733558
        "version": "2.0.0",
        "tasks": [
            {
                "type": "shell",
                "label": "gcc",
                "command": "gcc",
                "args": [
                    "-g",
                    "${file}",
                    "-o",
                    "${fileDirname}\\${fileBasenameNoExtension}.exe"
                ],
                "problemMatcher": {
                   "owner": "cpp",
                   "fileLocation":["relative","${workspaceRoot}"],
    
                }
            }
        ]
    }
    
  4. 错误提示:

    Executing task: gcc -g d:\oneDrive\personalCode\CLanguage\vscode\main.c -o d:\oneDrive\personalCode\CLanguage\vscode\main.exe <

    系统找不到指定的路径。

4189 次点击
所在节点    C
8 条回复
jht
2019-04-21 11:25:17 +08:00
有老哥遇到类似的问题吗?
jht
2019-04-21 11:31:09 +08:00
咦,手机端的排版好像乱了,兄弟们将就看一下吧~
mason961125
2019-04-21 15:43:37 +08:00
你的 gcc 在哪?加到 PATH 了吗?
jht
2019-04-21 17:34:20 +08:00
@mason961125 我用命令行可以编译的。
mason961125
2019-04-21 17:50:06 +08:00
@jht #4 command 那边你把路径写完整试试
jht
2019-04-21 19:26:00 +08:00
@mason961125 试了一下,还是提示这个这个。windows 平台的,重装 vscode 也没有解决。。。。
codechaser
2019-04-22 10:11:40 +08:00
反正我用 vscode 调试都是 launch.json 里把 program 设置成要调试的 exe 的完整路径。把 preluanch 注释掉。每次点击 build 之后才去 debug。这样不会有稀奇古怪的问题。
jht
2019-04-22 12:22:55 +08:00
@codechaser 如果是手动编译成了.exe 之后再按 F5 调试是没有问题的,就是使用 task.json 编译的时候会有问题。手动使用命令行编译是没有问题的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/557196

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX