- install (https://sourceforge.net/downloads/mingw) and configure MinGW with packages g++ gcc libc6-dev libtool pkg-config
- get gdb sources (I use 7.latest from https://www.gnu.org/software/gdb/) and put it into MinGW/msys/1.0 folder
- run ./configure in msys shell (MinGW\msys\1.0\msys.bat)
- run make and fix the following:
- hypot compile error with help of this '::hypot' has not been declared
- undefined constants for GetLastError function by adding
#include <winerror.h>into\gdb\gdbserver\win32-i386-low.c\gdb\gdbserver\win32-low.cgdb\ser-mingw.c
I have checked build process using 7.11.1 and 7.12.1 sources
7.12.1 x32 is broken under windows https://github.com/Alexpux/MINGW-packages/issues/1909 https://sourceforge.net/p/mingw-w64/bugs/576/
Answer from se_pavel on Stack Overflow- install (https://sourceforge.net/downloads/mingw) and configure MinGW with packages g++ gcc libc6-dev libtool pkg-config
- get gdb sources (I use 7.latest from https://www.gnu.org/software/gdb/) and put it into MinGW/msys/1.0 folder
- run ./configure in msys shell (MinGW\msys\1.0\msys.bat)
- run make and fix the following:
- hypot compile error with help of this '::hypot' has not been declared
- undefined constants for GetLastError function by adding
#include <winerror.h>into\gdb\gdbserver\win32-i386-low.c\gdb\gdbserver\win32-low.cgdb\ser-mingw.c
I have checked build process using 7.11.1 and 7.12.1 sources
7.12.1 x32 is broken under windows https://github.com/Alexpux/MINGW-packages/issues/1909 https://sourceforge.net/p/mingw-w64/bugs/576/
Answer from se_pavel on Stack OverflowVideos
No idea what MinGW Installation Manager is or why you were trying to use it when you are using msys2.
To install mingw64 gdb in msys2, you really just need to:
pacman -S mingw-w64-x86_64-gdb
You should probably run pacman -Syu twice before you run the above though.
As you can see, if you need other mingw64 builds of programs (toolchain programs or not), their package names would be prefixed with mingw-w64-x86_64-. There's also the package group mingw-w64-x86_64-toolchain which you can pacman -S --needed instead to get a somewhat full toolchain.
You may also want to use the urt64 toolchain instead. See this page for more details. (You can e.g. pacman -Ss gdb to find out what's the package name prefix for each of the variants.)
Note that to use any of the toolchain (or any non-msys2 builds of programs), you should use the corresponding "launcher" of shell/terminal instead of msys2.exe.
Check by restarting your PC, if it didn't work download the *.gdb file from its website (I guess it's a *.rar or some file), now update with MSYS and restart. It have solved for me, I guess it helps....
On my linux machine, I use gdb and it's great, but on my windows machine, gdb continuously crashes. I can't install an IDE for reasons, so I'm limited to command line options.
Additionally, I cannot use WSL2
If you are using WSL to compile the project you should not use MinGW gdb. You need to install gdb on you Linux subsystem (using native tools like apt if you are using Ubuntu WSL), reopen your project in WSL and configure the WSL path to gdb. I was able to successfully debug using this setup on WSL.
Replace your launch.json file with this file
{
"version": "0.2.0",
"configurations": [
{
"args": ["1"],
"name": "gcc.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
}
]
}
Make Sure you have installed MinGw Compiler and gdb debugger