Let's say you have a Windows PC on a 64 bit machine. Obviously, you have <a href="http://www.cygwin.com">Cygwin</a> because anything else would just be silly. Then you want to develop C-Applications that you can compile and run on large Linux-based servers, so you turn to an <a href="http://www.eclipse.org/">an IDE that can work with Cygwin</a>. Now here comes the twist: For whatever stubborn reason, you want to be able to compile your applications native 64 bit, and you want to do it in Eclipse, and you want to be able to debug them.
<span id="more-1051"></span>
It's been a while that I <a href="/2012/04/28/gmp-from-source-with-mingw-64/">blagged about GMP with MinGW-64</a>. Thanks to a very enlightening <a href="http://stackoverflow.com/questions/13423955/how-to-make-openmp-work-with-mingw-64-under-cygwin#13447314">stackoverflow answer</a>, I could catch a glimpse of how to use <b>./configure</b> in a less crude way ((Also, I now know that you have to add <b>/usr/x86_64-w64-mingw32/sys-root/mingw/bin</b> to your PATH in order to use OpenMP with MinGW 64.)). There's a quite <a href="http://www.gnu.org/prep/standards/html_node/Configuration.html">comprehensible document on configure parameters</a> which basically tells you everything you need to know. In fact, compiling GDB under cygwin using
```bash
./configure \
--build=i686-pc-cygwin \
--host=x86_64-w64-mingw32 \
--prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
make
make check
make install
```
will actually <b>install</b> GDB in such a way that
```bash
x86_64-w64-mingw32-gcc -o testfile testfile.c
```
now simply works! Note that with <a href="/2012/04/28/gmp-from-source-with-mingw-64/">my previous approach</a>, the <b>make install</b> would not work properly (for it did not know about /usr/x86_64-w64-mingw32/sys-root/mingw, of course). That made me think ‐ why don't I just setup eclipse to use <b>x86_64-w64-mingw32-gcc</b>? Like this:
<center><a href="http://blag.nullteilerfrei.de/wp-content/uploads/2012/11/gdb1.png"><img decoding="async" src="http://blag.nullteilerfrei.de/wp-content/uploads/2012/11/gdb1-300x159.png" alt="" title="gdb" width="300" height="159" class="alignnone size-medium wp-image-1069" srcset="https://blag.nullteilerfrei.de/wp-content/uploads/2012/11/gdb1-300x159.png 300w, https://blag.nullteilerfrei.de/wp-content/uploads/2012/11/gdb1.png 1010w" sizes="(max-width: 300px) 100vw, 300px" /></a><br>
<i>(remember to also change the linker and assembler executable)</i></center>
Well, the problem is, there doesn't yet seem to be a <a href="http://www.gnu.org/software/gdb/">GDB</a> coming with the x86_64-w64-mingw32-gcc. However, now that we know how to compile and install stuff, this is easy:
```bash
wget http://ftp.gnu.org/gnu/gdb/gdb-7.5.tar.gz
tar -xzf gdb-7.5.tar.gz
cd gdb-7.5/
./configure \
--build=i686-pc-cygwin \
--host=x86_64-w64-mingw32 \
--prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
make
make check
make install
```
And after that is done, set up eclipse to use the new gdb:
<center><a href="http://blag.nullteilerfrei.de/wp-content/uploads/2012/11/gdb.png"><img fetchpriority="high" decoding="async" src="http://blag.nullteilerfrei.de/wp-content/uploads/2012/11/gdb-300x233.png" alt="" title="gdb" width="300" height="233" class="alignnone size-medium wp-image-1067" srcset="https://blag.nullteilerfrei.de/wp-content/uploads/2012/11/gdb-300x233.png 300w, https://blag.nullteilerfrei.de/wp-content/uploads/2012/11/gdb.png 838w" sizes="(max-width: 300px) 100vw, 300px" /></a></center>
And voilĂ ! You can now compile and debug C applications in Eclipse in native 64 bit. In particular, debugging no longer suffers from the problems caused by 32 bit applications being virtualized.