Overview: Linux applications with Visual Studio
This document explains how building and debugging Linux applications works with VisualGDB: what tools are involved, how they communicate and what can be customized.
If you are looking for a step-by-step guide on building Linux applications with VisualGDB, read this tutorial.
Building and debugging Linux applications with VisualGDB involves 2 computers one Windows computer running Visual Studio and one Linux computer configured for SSH access.
VisualGDB seamlessly integrates the following tasks into Visual Studio
- Building your project
- Debugging the application
- IntelliSense support for Linux include files
Source file locations
When you create a VisualGDB-based Linux project for Visual Studio, the VisualGDB wizard allows choosing the directory on the Linux computer where the project will be stored. You will always have 2 instances of each source file: one on the Windows computer and another one on the Linux computer. The default Linux directory is /tmp/VisualGDB/<ProjectName>.
Building the project
When you build your Linux project with Visual Studio, VisualGDB will do the following in the background:
- Check whether you have added, renamed or deleted any source files. If yes, the Makefile will be automatically updated.
- Check if you have referenced any library projects made with VisualGDB. If yes, this will be reflected in the Makefile..
- If you are rebuilding the project, or the target directory on the Linux computer does not exist, all source files will be sent to the Linux computer. Otherwise, VisualGDB will check which files have been changed since last build and will only send them to the Linux computer.
- Finally, VisualGDB will launch GNU make on the Linux computer and let it build your application.
- If GNU Make or gcc reports any errors, VisualGDB will convert them to the Visual Studio format so that they will be shown in the Errors panel. The Linux file names will be automatically converted to the corresponding Windows file names.
Debugging your application
When you select Debug->Start Debugging with GDB in Visual Studio, VisualGDB will launch an instance of gdb (GNU Debugger) on the Linux computer and will control it in the background. The debugging experience with VisualGDB is not different from debugging a normal Windows application with Visual Studio: stepping, watch window, call stack, memory, disassembly and many other features are available. VisualGDB will also take care of file name conversion.
Additionally, you can always see what commands are sent to GDB using the GDB Session window and even send your own commands there if you are used to command-line debugging.
When you create or import a Linux project VisualGDB can query the remote computer for the standard include file locations, copy them to your Windows computer and add to the IntelliSense include locations for the project. As a result, the code suggestion will work just like for the Windows projects. You can always manage the cached directories later using the VisualGDB Project Properties window or in the Source Cache Manager.
If you want to read more about creating Linux applications with Visual Studio, see these tutorials:
- Creating your first Linux application with Visual Studio
- Importing an application from a Linux computer
- Creating static and dynamic Linux libraries