Compiling GDB Debugger in Windows

Here are the steps:

  1. Download 7-zip, if you do not have one.
  2. Install MinGW, please read MinGW’s Getting Started wiki. I choose manual installation:

    Download at least the following (or newer) packages from the MinGW download page:

    • binutils
    • gcc-core
    • mingw-runtime
    • w32api
    • expat

    Unpack them directly to D:\mingw

    GDB can use the Expat XML parsing library. This library may be included with your operating system distribution; if it is not, you can get the latest version from
    The `configure' script will search for this library in several standard locations; if it is installed in an unusual path, you can use the `–with-libexpat-prefix’ option to specify its location.

    Expat is used for:

    To download expat for MinGW, please visit here.

    For more about expat, please visit

  3. Install MinGW’s MSYS:
    • Install MSYS DTK 1.0 in D:\mingw\1.0
    • Install MSYS Core 1.0.11. It is an archive. Unpack it in D:\mingw\1.0
  4. Setting PATH and HOME environment, and run D:\mingw\1.0\msys.bat
  5. Download GDB debugger sources. I use the latest repository snapshot. And upack them to D:\mingw\1.0\home
  6. ./configure & make

You should have gdb.exe in D:\mingw\1.0\home\gdb-#.#.#\gdb\ in about 30 minutes.

To port GDB debugger to a new architecture, you should not miss the detailed guide ” Howto: Porting the GNU Debugger — Practical Experience with the OpenRISC 1000 Architecture “.


To compile GDB Insight 6.8 under MSYS environment, you should make a patch :

Index: gdb/ChangeLog
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.9174.2.20
diff -u -r1.9174.2.20 ChangeLog
— ChangeLog 31 Mar 2008 03:40:42 -0000 1.9174.2.20
+++ ChangeLog 11 Apr 2008 09:10:13 -0000
@@ -1,3 +1,8 @@
+2008-04-11 Hans Kester
+ * Added configdir for MinGW.
+ * configure: Added configdir for MinGW.
2008-03-30 Daniel Jacobowitz

* ia64-tdep.c (examine_prologue): Correct array access.

Index: gdb/
RCS file: /cvs/src/src/gdb/,v
retrieving revision 1.64
diff -u -r1.64
— 13 Jan 2008 12:23:05 -0000 1.64
+++ 11 Apr 2008 09:02:13 -0000
@@ -1445,7 +1445,7 @@

case “${host}” in
+*-*-cygwin* | *-*-mingw*)

Index: gdb/configure
RCS file: /cvs/src/src/gdb/configure,v
retrieving revision 1.242
diff -u -r1.242 configure
— configure 13 Jan 2008 12:23:04 -0000 1.242
+++ configure 11 Apr 2008 09:05:54 -0000
@@ -23080,7 +23080,7 @@

case “${host}” in
+*-*-cygwin* | *-*-mingw*)

This entry was posted in C++, Debug and tagged , , . Bookmark the permalink.

3 Responses to Compiling GDB Debugger in Windows

  1. ferdna says:

    I still get : “Can not parse XML library list; XML support was disabled at compile time”

    i tried “./configure –with-libexpat-prefix=/local/lib” & make and it doesn’t take expat… i do not know what i am doing wrong… please advice!

    pd. i am using Qt 4.6, MSYS and GDB 7.0… all of this in windows vista… i don’t think the patch you have here applies to this version…

  2. Zhou Renjian says:

    At the time of writing this post, GDB 7.0 is not released yet. The patch is for GDB 6.8.

    For libexpat, I suggest you to change PATH environment pointing to *.dll location or copy *.dll into System32 folder.

    Sorry I could not help you more, because I am not going to compile GDB 7.0 myself these days.

  3. Pingback: 用MSYS编译最新版本的GDB(git更新)(主要针对WIN平台) » HelloGCC -- Open Source Toolchain Blog