Program Output No Longer Appears In Integrated Terminal

537 views Asked by At

Previously, when I tried to debug in VSCode on Windows 10 using the C/C++ extension and MinGW32's g++ and gdb, I was able to press F5(the default "start debugging" hotkey), set up my tasks.json and launch.json, and the program's output would appear in the integrated terminal, as well as any prompts for input. This was useful especially when I needed to also provide input to the program while debugging it for schoolwork, without opening an external shell. However, this is no longer the case and I'm confused as to why, as I haven't actively changed anything to cause this to occur, and now all program output is appearing in the Debug Console, where I cannot enter input. I'd prefer to restore things to what I've described above, where all output/input occurs in the integrated terminal, but I'm unsure how I would accomplish this. I have tried to debug Python programs in VSCode as well, using the available Python extension, but the output of print statements appears in the integrated terminal, where I'd expect it to. In addition, the Code Runner extension works with my current issue, but I'd prefer to restore my working environment to its' previous state. My current version of VSCode is 1.49.2, my C/C++ extension version is 1.0.1, and my Python extension version is 2020.9.111407. I am also using g++.exe (MinGW.org GCC Build-20200227-1) 9.2.0 and GNU gdb (GDB) 7.6.1

For maximum clarity, compiling and debugging from the integrated terminal by manually typing the g++ and gdb commands works fine, but F5 no longer produces the behavior I'd expect.

I've made sure that my launch.json has "externalConsole": false set properly, my Terminal: Explorer Kind setting is set to "integrated", and Terminal > Integrated: Inherit Env is set to true. I've tried to toggle all of these options, running in Administrator mode, running in compatibility mode for Windows 8, rolling back to old versions of the extensions I'm using, and nothing has changed this behavior.

tasks.json:

{
"tasks": [
    {
        "type": "shell",
        "label": "C/C++: g++.exe build active file",
        "command": "C:\\Programming\\MinGW32\\bin\\g++.exe",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe"
        ],
        "options": {
            "cwd": "${workspaceFolder}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
],
"version": "2.0.0"
}

launch.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": [
    {
        "name": "g++.exe - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\Programming\\MinGW32\\bin\\gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "C/C++: g++.exe build active file"
    }
]
}

test.cpp:

#include <iostream>

using namespace std;

int main() {
    cout << "Hello\n";

    system("pause");
    return 0;
}

This is what happens when I press F5 on a python file, this is the kind of behavior I'd expect.

This is what happens when I press F5 on my cpp file, no output appears in the integrated terminal.

Instead, it appears here.

I have chosen to omit the code from my .py file in the first image due to its' simplicity

UPDATE(Sept. 28, 2020): Apparently this issue has been documented here, and the solution that worked for me was to install mingw-w64 from their sourceforge, then update my mingw path in system environment variables.

1

There are 1 answers

0
du11jk On

The only solution I found is to set "externalConsole": true, in launch.json, working in the external console instead.