Cannot build and debug because the active file is not a C or C++ source file. macos
twinkletwinklelilstar opened this issue · comments
Environment
- OS and version:
- VS Code:
- C/C++ extension:
- OS and version of remote machine (if applicable):
- GDB / LLDB version:
Bug Summary and Steps to Reproduce
I downloaded vscode and try to add c++ extension to start coding. But when i add clang c++ or g++ i begin to have issues. When i click run c/c++ file and click g++ or clang++ build and active debug file. There's always some issues. Either it is showing "Cannot build and debug because the active file is not a C or C++ source file." or simply not running. Plz help.
Debugger Configurations
launch.json file:
{
// 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": []
}
tasks.json file:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"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"
}
Debugger Logs
sry idk how to log, i tried the tutorial but it doesn't work
Other Extensions
installed c++ and code runner extension. But i also have issues with installing the extensions from the first place. i couldn't install it from the vscode app, and i did it thru marketplace and downloaded vsix files from there.
Additional Information
No response
it is also showing "The preLaunchTask 'C/C++: g++ build active file' terminated with exit code -1." when i try to run.
This is possibly caused by an issue with your configuration. Could you check the following things:
-
Are you compiling a C++ file? If so, could you make sure your currently selected compiler is a g++ compiler and not a c++ compiler.
-
Could you provide the output from C/C++: Log Diagnostics when you open the C++ file you are having an issue with?
Hello. Thank you for helping me and responding to this.
- Yes i am trying to compile a C++ file. I believe I am using a g++ complier, but to double check. May I know how can I check which complier I am using?
- My output section is blank when i try to run my C++ file, it just shows "Cannot build and debug because the active file is not a C or C++ source file."
I am only trying to run a simple code, so i don't understand why it is not working:
#include
int main(){
std::cout << "I like pizza.";
return 0;
}
I am sorry but I am not sure where can I find the log diagnostics that you want. This is my first time using vs code so I am unsure about lots of things. Can you please lmk where i can find them? Thank you!!