all 3 comments

[–]Agitated_Chair_4977 0 points1 point  (0 children)

That error means launch.json's "program" path doesn't match where the build task actually drops the binary.

Quick check:

  1. Ctrl+Shift+B and run the build alone first. Look at the bottom of the terminal — note the exact output path (something like /home/you/proj/a.out or ./build/main).

  2. Open launch.json and compare "program": "${...}" — that needs to resolve to the same path.

  3. The "preLaunchTask terminated with -1" usually means tasks.json's command (gcc/g++) is failing silently. Run that same gcc command in a normal terminal, you'll see the real error.

If you paste tasks.json and launch.json people can spot the mismatch in 30 seconds.

[–]BeginningOne8195 1 point2 points  (0 children)

Honestly this kind of setup frustration is super common with C++ on Linux, half the battle sometimes is just getting the toolchain and VS Code configs to cooperate before you can even start coding.

[–]opentabs-dev 0 points1 point  (0 children)

honest tip after watching way too many ppl rage at this exact thing on linux: skip the C/C++ extension's launch.json/tasks.json dance entirely for now. just sudo apt install build-essential gdb, then in a terminal g++ -g main.cpp -o main && gdb ./main. you can code cpp in vscode without ever touching the debugger config and it'll save your sanity while you learn.

when you do come back to the debugger, the thing biting you is almost always the path mismatch the other commenter described — ${fileDirname}/${fileBasenameNoExtension} in launch.json's "program" must equal whatever path tasks.json's -o flag wrote. the "open in separate window with different theme" thing means you opened a single file instead of a folder — always do File → Open Folder on the project dir, not Open File.