Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Tutorial: Developing a Raspberry PI app with Visual Studio

1 of 6

Products
Download
Download VisualGDB
Buy VisualGDB
Version history

Downloads

http://visualgdb.com/tutorials/raspberry/

Tutorials

Support

Contact

Developing a Raspberry PI app with Visual Studio


This tutorial demonstrates how to build and debug a simple Raspberry PI application using Visual
Studio.
1. If you have not prepared your SD card yet, download WinFLASHTool and use it to write the image to
the SD card:

Tutorials
Tutorial list
MinGW projects
MinGW64 projects
Cygwin projects
Importing cygwin apps
Quick Debug (Win32)
Debugging GNU tools

Embedded
MSP430 devices
MSP430 UART
STM32 devices
AT91SAM7 devices
OpenOCD setup
ST-Link debugging
Texane/ST-Link
STM32F4-Discovery
STM32 Timers
Freescale Kinetis
FRDM-KL25Z
KL25Z RGB LEDs
Freescale TWR-K60
STM32 PWM
STM32 FPU
STM32 UART
ARM Semihosting
STM32 USB CDC
NXP LPC
Legacy devices
Threads
Stand-alone projects
Newlib-nano
CC3200 WiFi
IntelliSense

2. Start your Raspberry PI and connect a network cable to it.


3. Please download and install the latest VisualGDB.
4. On your Windows machine start Visual Studio, select "File->New project". Then select
"VisualGDB->Linux Project Wizard". Specify project location and press "OK".

Linux Tutorials
Creating Linux apps
Importing Linux apps
Linux Libraries
Quick Debug (Linux)
Embedded Linux apps
Fixing breakpoints
Attaching to apps
GNU Octave plugins
LLVM/clang
Core dumps
Qt Linux apps

4/28/2015 5:54 AM

Tutorial: Developing a Raspberry PI app with Visual Studio

2 of 6

Converting to custom
ImageMagick library
OpenGL Linux apps
QT5 on Ubuntu

http://visualgdb.com/tutorials/raspberry/

5. The VisualGDB Linux Project Wizard will start. As we are making a simple "Hello, World" application,
keep "Create a new project" selected and press "Next".

Android Tutorials
Android quickstart
Android Studio
Co-debug with Eclipse
Vs-android projects
Android IntelliSense
Android libraries
Setup USB debugging
Using Intel HAXM
Hello-jni
Hello-gl2
Hello-neon
San-angeles
Bitmap-plasma
Native-plasma
Native-activity
Native-audio
Two-libs
Breakpoint problems
Fixing breakpoints
Debugging APK Files
Developing for OUYA
Qt on Android
Cocos2d-x
Command-line tool
Isolated processes
VMWare Support

Beaglebone
Beaglebone C++
Cross-compiling
Qt-Embedded
Qt-X11

6. If you have not created any Raspberry PI projects before, select "Create a new SSH connection" on
the next page.

Raspberry PI
Raspberry PI basics
Blinking LED
Cross-compiler
Qt applications
WiringPI
Cross-compiling QT

Cubieboard
Cubieboard C++
Cross-compiling

Porting tutorials
Windows to Linux
QT Applications

Customizations
Per-user variables
Custom steps
Custom shortcuts

4/28/2015 5:54 AM

Tutorial: Developing a Raspberry PI app with Visual Studio

3 of 6

http://visualgdb.com/tutorials/raspberry/

VisualGDB SDK
Getting started
Array visualizer
SDK Reference

Documentation

7. Provide the IP address of your Raspbery PI box, the user name ("pi" by default) and password
("raspberry" by default). It is recommended to check the "setup public key" checkbox, so that
VisualGDB will automatically generate an public/private keypair, store it in your Windows account's
key container and setup the Raspberry PI box to use it.

GDB commands
Linux targets
Auto source download
Embedded targets
Project Variables
Source cache
Debugging Tricks
Environment
Makefiles
Android Startup
Path mapping
Android GDB versions
Finding app path
FAQ
Troubleshooting

Tools
ADB fix
USB driver tool
QT Cross-compiler
If you don't enable public key authentication, VisualGDB will remember your password for this
connection. The stored passwords are encrypted using a key stored in your Windows account. Thus,
the password will only be available once you login using your Windows account.
8. You could use 2 options to build your first Raspberry PI app: build it on Windows with a cross-compiler
or build it on the Raspberry PI itself. The first option is faster, while the second is easier to setup. In
this tutorial we will use the second option:

4/28/2015 5:54 AM

Tutorial: Developing a Raspberry PI app with Visual Studio

4 of 6

http://visualgdb.com/tutorials/raspberry/

Use the diagram at the bottom of the page to check the correctness of your setup:
The hammer icon corresponds to the machine where the compiler is run.
The "play" icon corresponds to the machine where the debugged program is launched.
9. When you press "Next", VisualGDB will test your toolchain by trying to compile and run a trivial
program. If any errors are detected at this stage, you will see a detailed error log with further
troubleshooting information.

10. As the same source code will be edited under Windows and then compiled under Linux, VisualGDB
will need to keep the sources synchronized. The easiest way is to use automatic file uploading via
SSH.

11. Press Finish to complete the wizard. If this is your first project for Raspberry PI, VisualGDB will cache
the include directories to make them available through IntelliSense.

4/28/2015 5:54 AM

Tutorial: Developing a Raspberry PI app with Visual Studio

5 of 6

http://visualgdb.com/tutorials/raspberry/

12. Replace the contents of the main source file with the following:
#include <stdio.h>
#include <unistd.h>
using namespace std;
int main(int argc, char *argv[])
{
char szHost[128];
gethostname(szHost, sizeof(szHost));
printf("The host name is %s\n", szHost);
return 0;
}
13. Build the solution. You will see how the source files are transferred to Raspberry PI and compiled
there:

14. Set a breakpoint on the printf() line and press F5 to start debugging. The breakpoint will trigger:

4/28/2015 5:54 AM

Tutorial: Developing a Raspberry PI app with Visual Studio

6 of 6

http://visualgdb.com/tutorials/raspberry/

15. You can now use all normal Visual Studio techniques to debug your app. If you want more examples,
check out the following tutorials:
Using cross-compiler to build Raspberry PI apps
Cross-compiling QT apps for Raspberry PI
Creating Linux apps with Visual Studio
If you want to develop a kernel module for Raspberry PI an debug it over JTAG, follow this tutorial.

Share

Follow

Tweet

63

Like

315

2015 Sysprogs O. All rights reserved. - Impressum | Terms of Use | Copyright | Privacy Policy

4/28/2015 5:54 AM

You might also like