[Solved] the preLaunchTask 'C/C++:gcc.exe build active file' terminated with exit code -1 (VS Code)

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ส.ค. 2023
  • Solve 'The preLaunchTask 'C/C++:gcc.exe build active file' terminated with exit code -1' error in Visual Studio Code with our comprehensive guide. Learn about GCC, the integrated terminal, and tips for debugging C++ programs in VS Code.
    Article: www.techrbun.com/solve-pre-la...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 41

  • @real.l_ryozaki
    @real.l_ryozaki 9 หลายเดือนก่อน +51

    Is this issue rare? Why no one is making videos on how to solve this issue? I think we have to ask Visual studio code team directly to state how to fix this in there website

  • @seungxx3051
    @seungxx3051 3 หลายเดือนก่อน +14

    if anyone is still having this issue
    1. From the "Edit Configurations (UI)" access the "c_cpp_properties.json" file and change the "compilerPath" to g++.exe instead of gcc.exe.
    2. In the folder of your cpp file you'll find a ".vscode" folder. Open the file "tasks.json" inside it.
    3. Change the "command" path to g++.exe instead of gcc.exe

    • @savinavsharma3133
      @savinavsharma3133 3 หลายเดือนก่อน

      what about mac?

    • @Darker005
      @Darker005 3 หลายเดือนก่อน +1

      it worked thank you so much bro

    • @ebubechidolue3420
      @ebubechidolue3420 3 หลายเดือนก่อน +1

      Thanks

    • @monicalao7652
      @monicalao7652 หลายเดือนก่อน

      Thank you so much man you are the actual goat

    • @knightofmathematics
      @knightofmathematics หลายเดือนก่อน

      In my installation, in order to apply your solution, I found that I had to completely remove the lines
      {
      "type": "cppbuild",
      "label": "C/C++: gcc.exe build active file",
      "command": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
      "args": [
      "-fdiagnostics-color=always",
      "-g",
      "${file}",
      "-o",
      "${fileDirname}\\${fileBasenameNoExtension}.exe"
      ],
      "options": {
      "cwd": "${fileDirname}"
      },
      "problemMatcher": [
      "$gcc"
      ],
      "group": {
      "kind": "build",
      "isDefault": true
      },
      "detail": "Task generated by Debugger."
      }
      from tasks.json and only leave the corresponding ones with g++. That's how I got it to work.
      I first tried placing the g++ ones above the ones with gcc, but that didn't work. So, I deleted the section on gcc entirely.
      I hope I have done the right thing.

  • @PePe-is8wj
    @PePe-is8wj 7 หลายเดือนก่อน +39

    I had this problem and for me the cause was vscode tried compiling c++ file with gcc. gcc doesn't have access to standard c++ lib needed for std::cout, so my std::cout

  • @mazharulalam3885
    @mazharulalam3885 10 หลายเดือนก่อน +10

    there is no c/c++: edit configurations (ui)“ in command palette, i have followed all previous tasks as you said

    • @pauliusjakelaitis8137
      @pauliusjakelaitis8137 8 หลายเดือนก่อน

      make sure you use ctrl+shift+p to open the command palette and not just left click on it

  • @Jita-bd9ft
    @Jita-bd9ft 10 วันที่ผ่านมา

    I am not able run large programs .....The problem was resolved for small codes.....Please help

  • @rururi3262
    @rururi3262 9 หลายเดือนก่อน +5

    issue is still not solved, though i checked everything you mentioned.

    • @apoorvbagal2936
      @apoorvbagal2936 6 หลายเดือนก่อน

      There must be something wrong in your tasks.json file

  • @bhagatalisha
    @bhagatalisha 10 หลายเดือนก่อน +3

    My Problem got solved but next day again appeared

    • @mazharulalam3885
      @mazharulalam3885 10 หลายเดือนก่อน +1

      I have been using code runner extension to build and run the cpp file this extension conflicts with the cpp extension pack, so i have disabled it then issue solved..

    • @ioanungureanu1429
      @ioanungureanu1429 9 หลายเดือนก่อน +1

      have you finally solved it ?

    • @boredboi1903
      @boredboi1903 5 หลายเดือนก่อน

      thank you so much man.. this disabling technique works like a charm@@mazharulalam3885