Last active
January 8, 2023 06:27
-
-
Save Shivam60/92feac1a9943d7bedfddaa46c3698848 to your computer and use it in GitHub Desktop.
vscode tasks.json to Build & debug C++ programs using mingw64 g++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"tasks": [ | |
{ | |
"type": "cppbuild", | |
"label": "C/C++: g++.exe build active file", | |
"command": "C:\\msys64\\mingw64\\bin\\g++.exe", | |
"args": [ | |
"-static-libstdc++", | |
"-fdiagnostics-color=always", | |
"-g", | |
"${file}", | |
"-o", | |
"${fileDirname}\\${fileBasenameNoExtension}.exe" | |
], | |
"options": { | |
"cwd": "${fileDirname}" | |
}, | |
"problemMatcher": [ | |
"$gcc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
}, | |
"detail": "Task generated by Debugger." | |
} | |
], | |
"version": "2.0.0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a standard
task
which gets generated the first time we try to debug a C++ program in vscode as we follow its instructions on setting up C++.They key missing argument here is
-static-libstdc++
I was getting error in debug console window of vscode terminal
During startup program exited with code 0xc0000139.
to the standard program that was mentioned in the official vscode instructions.I tried to build the program from terminal using the command
g++ hello-world.cpp -o hello.exe
which it did successfully.Then I commented out the vector declaration and program built and I was able to debug. This was a good hint and on further searching I found out that I was missing the
libstdc++-6.dll
or had two copies of it. This was the case for the terminal in which vscode was executing my program.Googling the exact fix led me to libstdc++-6.dll