My source file.cpp:
#include <iostream>
using namespace std;
int main()
{
int x = 1;
int y = 2;
cout << x + y << endl;
return 0;
}
I compile it using g++ -g file.cpp, and then my launch.json file is like so:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
My directory structure is:
- workspaceFolder
- .vscode
- launch.json
- a.out
- file.cpp
When I click the green "Start debugging" arrow in the Debug tab I get this error in the Debug Console:
Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object
What am I doing wrong? I have looked at every tutorial and debugging C++ seems to be working for all of them except in my case. I also have the C/C++ (Microsoft) extension installed, and am running Ubuntu 64-bit.