8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[VSCode]macOSでC/C++のデバッグができなくなった時の対処法

Last updated at Posted at 2019-10-28

#デバッグができない
かなしい😢

##エラーメッセージは様々
Unable to create 'launch.json' file inside the '.vscode' folder (Cannot read property 'length' of undefined).
だとか
いざデバッガが走り出してもBreakpointでストップしないだとか
ここにとりあえずの対処法がありました

##解決法

  1. 以下のコマンドを実行
mkdir .vscode
touch .vscode/launch.json
touch .vscode/tasks.json
  • jsonファイルをそれぞれ編集
tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "clang++ build active file",
      "type": "shell",
      "command": "clang++",
      "args": ["${fileBasename}", "-o", "${fileBasenameNoExtension}.out", "-g"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}
launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "clang++ build and debug active file",
      "type": "lldb",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}.out",
      "args": [],
      "cwd": "${workspaceFolder}",
      "preLaunchTask": "clang++ build active file"
    }
  ]
}
  • ⌘ + Shift + bでコンパイル
  • あとは通常通り

##おわりに
根本的原因等誰かわかりましたら教えてください...

##追記
「macOS Catalinaへの更新時にデバッグできなくなった時の対処法」としていましたが、未だにこの問題があるようなのでタイトルを更新しました。

8
7
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?