Using Visual Studio to debug Cygwin applications
This tutorial shows how to create, build and debug cygwin-based applications with Visual Studio.
Before you begin, please install cygwin and VisualGDB .
- Start Visual Studio. Select File->New project->Visual
C++->VisualGDB->Visual GDB Project Wizard
Select
project location and enter a project name. Then click OK. - In the VisualGDB wizard select "A Windows Application":

- On the next page select "Create a new project"

- On the toolchain page select "Cygwin". VisualGDB will
detect its location automatically or ask you to enter it in
case it cannot be found.
If
you want to see or customize the compiler/debugger versions,
press the "Setup individual tools" button. - The build settings page allows editing the flags going into the makefile. In our case no changes are needed, press Next.

- Next you can customize various debugger settings. In
this tutorial we'll accept the default settings and press
Next.

- Next page allows you to modify how file names in cygwin
error messages will be converted to Win32 paths compatible
with Visual Studio. Just click Next to accept the default
settings.

- On the next page you can customize the include
directories used by Visual Studio to suggest function
arguments and browse structures. You can import those
automatically from GCC by clicking at the link at the bottom
of the wizard page. Press Finish to make the project.

- The wizard will generate a Visual Studio project for a
simple "Hello, World" application built with cygwin tools.
To build it just select Build->Build Solution
or press Ctrl+Shift+B.

- Once the project is built, set a breakpoint on the
printf() line and start debugging by selecting Debug->Start
debugging with GDB:

- Debugging your cygwin-based app with VisualGDB is not
much different from debugging normal Windows applications:
stepping, watch windows, call stack, memory view and many
other features will work as usual. VisualGDB will seamlessly
control the GDB debugger on behalf of Visual Studio. You can
also enter GDB commands directly in the GDB Session window.
To
end debugging, press Shift+F5. - You can always customize the GDB-specific properties of
your project by right-clicking at it and selecting
"VisualGDB Project Properties".

- From the properties window you can control GCC/GDB
command lines and many advanced parameters.

| Follow @sysprogs Tweet |
