Rob Yart
Rob Yart

Reputation: 333

VS Code does not show output from a program

I've created a c++ project on ubuntu in visual studio code. It launches the program using gdb mode, but does not show anything in Output. When I launch program from console, the output is present. I tried inserting "console" property, but vscode tells me, that it is forbidden (from similar issue with node https://github.com/Microsoft/vscode/issues/30842).

How can I enable vscode to show the output from my program?

{
    "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
                }
            ]
        }
    ]
}

Upvotes: 13

Views: 59672

Answers (3)

Bhargav Sonagara
Bhargav Sonagara

Reputation: 1

Add this line in setting.json in code-runner.executorMap

"cpp": "g++ -o $fileNameWithoutExt $fileNameWithoutExt.cpp && ./$fileNameWithoutExt"

Upvotes: -2

Rob Yart
Rob Yart

Reputation: 333

The program was launched in external terminal and due to the configuration of my screen I didn't see it. Everything works fine.

Upvotes: 1

3CxEZiVlQ
3CxEZiVlQ

Reputation: 38332

You config is correct. The program output should be in the DEBUG CONSOLE.

Menu | Debug Console or Ctrl+Shift+Y.

Upvotes: 11

Related Questions