microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

the prelaunchtask c/c++: gcc build active file terminated with exit code -1

Sabri-Allam opened this issue · comments

Environment

  • OS and Version: windows 11
  • VS Code Version: visual code (latest version)
  • C/C++ Extension Version: v1.20.5
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Bug Summary: I am trying to learn C language with openclassroom. Downloaded WSL and Ubuntu, then C/C++ extension for visual code and followed every step. Created my first directory ('projects' then 'myfirstproject') and first files ('helloworld.c' and 'variables.c') without any problems. I can run them in VC without any issue.

Now i've tried to created a new directory and new files. Everytime I try to run the files in visual code it tells me : the prelaunchtask c/c++: gcc build active file terminated with exit code -1. Then when I try to debug it it tells me : launch: program '/home/my_username/projects/myfirstprogram/main' does not exist.

I've read everything I could find about this error. I've tried to add my GCC to "PATH", I've relaunched my computer, I've tried uninstalling ubuntu and wsl and reinstalling them... Now i can't even find the files and directory in wsl.localhost anymore. I'm a beginner when it comes to all of this and I'm honestly at a loss for what to do...

The code I'm trying to reproduce is in the first video of this page : https://openclassrooms.com/fr/courses/19980-apprenez-a-programmer-en-c/7528516-initiez-vous-a-la-programmation-modulaire.

I hope you'll be able to help me, thank you!!

Configuration and Logs

I don't have any, all the .json files i have are lauch.json :
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": []
}

and tasks.json :
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc-11 build active file",
            "command": "/usr/bin/gcc-11",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

Other Extensions

No response

Additional context

No response