READ THIS:
I've already solved the problem by changing the compiler path from /usr/bin/gcc to /usr/bin/g++. Anyways, you can go ahead and close this question. But I've got a doubt: Why is the gcc compiler not working? Is it because I'm compiling c++ and not c? If there is someone so keen to read the following and perhaps clearing my doubt, it would be awesome. But again, you can go ahead and close this question if you want to. Thanks beforehand, stackoverflow community!
THE PROBLEM
I'm programming on c++ in a linux platform in Chrome OS with the IDE Visual Studio code. Every other project had been builded, debuged, compiled and runned as expected. However, one day it happened that the IDE doesn't recognize the files I put into them (.cpp). The files can be built, but can't it still shows an error message (code 42). For instance, whenever I try to build or run any .cpp file, it tells me that the program exited with exit code 42. And a window oppens telling me the following:
The preLaunchTask 'C/C++: gcc build active file' terminated with exit code -1
2 days before I downloaded the openAI API C++ library. Did that cause this to happen? Moreover, when I opene the file without the .cpp it now says something of openai API at the start of the document. That didn't happen before.
I also tried by doing what the first answer of this question said (Error: the preLaunchTask build terminated with exit code -1, launch program does not exist). Now the error changes, which is: The preLaunchTask 'C/C++: cpp build active file' terminated with exit code -1.
This is my launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++: g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file"
}
]
}
This is my tasks.json file:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${fileDirname}\\**.cpp",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: cpp build active file",
"command": "/usr/bin/cpp",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
And this is my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++20",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
Nevertheless, the program building works only in the terminal, with the following commands
g++ fileName.cpp -o fileName.exe ./fileName.exe
But if I do the same with the "gcc"" command, it exits with "ld returned 1 exit status"
Does this mean that somehow my gcc debugger is defectous?