- 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....
Steps to add gdb.exe Open MinGW Installation Manager select package "mingw32-gdb" from the list. Then select "Apply Changes" in Installation menu. This will automatically install gdb.exe in the path C:\MinGW\bin.
Please let me suggest you debugger program TDM-GCC. For download and install visit
http://wiki.codeblocks.org/index.php?title=MinGW_installation
Because a debugger program (toolchain) is very complex undertaking, is not standard in Code::Blocks. You must download it and install on Code::Blocks.
Note: It is impossible copy and paste images here. In the case linked page changes, I, or another one, should suggest new link.
However following are instructions according to images and my experience.
Download TDM-GCC from https://jmeubank.github.io/tdm-gcc/download/ click [tdm64-gcc-10.3.0-2.exe] and run it.
In Wizard Action window - Click [Create].
In Select Edition window - If MinGW/TDM (32-bit) is not checked, check it. Click [Next>].
In Licence Changes window - Click [Next>].
In New Instalation: Instalation Directory window - If text box is "C:\TDM-GCC-32", it's okay. If is not, click [Browse ...], and navigate: C:\ > TDM-GCC-32 > click [OK]. Now text box is C:\TDM-GCC-32. Click [Next>].
If a small window appears saying The directory TDM-GCC-32 is not empty! Are you sure you want to install here?. Click [Yes].
In New Installation: Download Mirror window - Click [Next>].
In New Installation: Choose Components window - Check whether Add to PATH box is checked. Actually is checked. Click [Install].
In Installing window - Wait till [Next] become black. Then click it. Even if Instalation Failed window appears click [Next].
In Completing the TDM-GCC Setup Wizard window - Click [Finish].
Go to Code Blocks > Settings > Compiler.
10a. In Global compiler settings window click "Toolchain executables". Just below, find "Compiler's installation directory". If the below text field is C:\TDM-GCC-32, it's okay. If not, click the [...] at the end of the field. In "Select directory" wizard, navigate to C:\TDM-GCC-32. Now "Folder:" should be TDM-GCC-32. Click [Select a folder] in "Select directory" wizard.
10b. In Global compiler settings. Below red "Note:..." find "Program Files" > "Debuger". If text field reads "GDB/CDB debuger : Default", it's okay, click [OK]. If not, click the down arrow at the end of the field > choose "GDB/CDB debuger : Default". Check that text field is "GDB/CDB debuger : Default". Click [OK].
Go to Code Blocks > Settings > Debugger... . In Common window, left list, click "Default". If "Executable path:"'s text field is "C:\TDM-GCC-32\bin\gdb32.exe", it's okay, click [OK]. If not, click [...] button and navigate C: > TDM-GCC-32 > bin > click gdb32 (or gdb32.exe) file > click [open] in "Select executable file" wizard. "Executable path:" should be C:\TDM-GCC-32\bin\gdb32.exe. Click [OK]. Now you can debug your program.
If Debugger does not function, close Code Blocks and restart them.
Regards.