Visual Studio (2012) template and the Raspberry Pi Toolchain C++

Hi All,

after recently acquiring my raspberry pi and deciding I wanted to do something cool with it in C++ I started looking around for a tool chain for C++ and Visual Studio. Everything I found was either designed for eclipse (which I love for Java, just not C++!) or very expensive and extremely buggy so I have decided to do my own.

After working around for a few days, I have managed to get a tool chain working between Visual Studio and Raspberry Pi. This tool chain has two build strains, one debug and one release. The debug is compiled using G++ for x86 and the Release is compiled using G++ for ARM. This is a zip file for a template for Visual Studio 2012. It includes a sample program, which you can use to test to see if it is working.

Version 1 of the Raspberry Visual Studio C++ template

Initially, if you hit f7 in either release or build you will get a file not found error in Visual studio, so just import it for now.

To import the template, copy the zipped file to your “Documents\Visual Studio 2012\Templates\ProjectTemplatess” folder and restart Visual Studio.

Next we need import the build tools.

Firstly we need to grab a copy of CYGWIN. Download the setup.exe from the website. Begin the installation, and when you reach the select packages install screen, make sure you click the ‘Default link’ next to the ‘Devel’ category, then click next, this bit takes a while so go make yourself a brew, or relax, as this can be pretty large.

Secondly we need to grab a copy of the raspberry pi g++ cross compile tools.

Download the zip file from and choose the file appropriate for you::

  •” for hard float.
  •” for soft float.

Create a folder within your “C:\Cygwin\Opt” folder called ‘crosstools‘ and extract the ‘arm-unknown-linux-gnueabi‘ into this folder.

The final path should be “C:\cygwin\opt\crosstools\arm-unknown-linux-gnueabi\

Finally, we need to add the path to our environment variables.

  1. On the Start menu, right-click Computer.
  2. On the context menu, click Properties.
  3. In the System dialog box, click Advanced system settings.
  4. On the Advanced tab of the System Properties dialog box, click Environment Variables.
  5. In the System Variables box of the Environment Variables dialog box, scroll to Path and select it.
  6. Click the lower of the two Edit buttons in the dialog box.
  7. In the Edit System Variable dialog box, scroll to the end of the string in the Variable value box and add a semicolon (;).
  8. Add the following path’s after the semicolon: c:\cygwin\opt\crosstools\arm-unknown-linux-gnueabi\bin;c:\cygwin\bin;
  9. Click OK in three successive dialog boxes, and then close the System dialog box.

Start a command prompt and type the following:

g++-4 –version

you should see the following

g++-4 (GCC) 4.5.3

Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

now type the following command:

arm-unknown-linux-gnueabi-g++ –version

you should see the following output

arm-unknown-linux-gnueabi-g++ (crosstool-NG 1.15.2) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

This should mean everything is working.

Finally, open Visual Studio, click on projects and look for Raspi.

Create a new project, and hit f5, you will see an error message saying VS cannot find debug information, this is good!

Select the release, hit f5, you will see an error message saying ‘Unable to start program ./xxxxx/ProjectName.exe’, this is also good!

You will find your executable(s) in the projectfolder/debug and projectfolder/release respectively. Debug will run within windows, Release will not.

I am in the process of writing a tool to automatically deploy these to the pi, and giving you the ability to debug in VS.

If you feel like being generous and have a few extra pennies hit the donate button on the right! Enjoy!
– H


  1. jclarkmm2

    I repeated your procedure. And it worked. The first time. Unbelievable!

  2. Jockey4her

    I didn’t have as good a luck as jclark up there. Maybe you can help me?

    I get a “g++-4 is not recognized as an internal or external command”.. etc. Which sounds like some sort of path issue if it can’t find g++ in there??

    I added your two items to Environment Path, and they appear at the end if I type path. c:\cygwin\opt\crosstools\arm-unknown-linux-gnueabi\bin;c:\cygwin\bin;

    The install directory is:

    Just to be clear, inside that directory is another arm-unknown-Linux-gnueabi folder as well as bin, include, lib etc.

    Looking forward to getting it working!

    • Jockey4her

      Nevermind. Got it.

      I guess for those of use who are totally unfamiliar with Cygwin and gnu stuff, you might want a few more details. Like I had no idea there were two gcc installers, and didn’t know which was which.

      Please indicate the g++, and the names of those packages. The list is really long, and a lot of them look the same.

    • Jockey4her

      Once again, hit some sort of issue.

      When I build the RaspiV11 blank project, the “hello world” I get this error.

      Error 1 error MSB3073: The command “g++-4 *.cpp -pass-exit-codes -g -o Debug\RaspiV11.exe” exited with code 127. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets 38 5 RaspiV11

      Is there something missing? I verified that arm-unknown-linux-gnueabi-g++ –version is functional.


    • Jockey4her

      Ooops. You are right again! You are always right. I will just have to remember that!!

      Thanks. Hope you can get the deploy and debug working soon. (just so you can watch me screw up the installation!)

  3. Admin (Author)

    Hi Jockey4her,

    Please see the link to the Raspberry Pi tools, download the zip, and just pick either the hard float or the soft float depending on your Operating System.

    Unzip the files into your Cygwin installation and it should just plug and play. (After you’ve set up your environment variables)

    should take you to the files,

    Best Regards,


  4. iys

    Nice work! Any progress on deployment/debugging?

    • Admin (Author)

      Hi, I took a break from this, sorry for the late reply!

      I am still working on this but due to personal commitments I haven’t had the time. It’s still in the pipeline though!

      – H

  5. HopWorks

    I’m stuck unfortunately. I added to my environment variable but I had to change the path a bit because I installed cygwin64.

    After I did that and went to enter what you said at a command prompt, I had the same issue as Jockey4her but unlike him, I didn’t figure it out. And I am curious as to what the path at c:\cygwin64\opt\crosstools\arm-unknown-linux-gnueabi\ is suppose to look like. I have another arm-unknown-linux-gnueabi directory in there, and inside that another bin, etc. Is g++-4 all one word with no spaces? I do not see a g++-4, just g++.exe and I copied and pasted from here for the command line.

    • Admin (Author)

      Hi Gary,

      Sorry for taking so long to get back to you. If you are still having issues with the calls to G++ and G++-4 I would check your environment variables in Windows. If they are there, try moving them to the beginning, and restart your command prompt/Cygwin. If you are still having issue, let me know and respond more quickly for you!


  6. DrWheetos

    I’m just starting this journey with a Raspberry Pi and will be following your article to start developing for the Pi using VS2012 too. I’ve already been using VS2012 for some months to develop some C programs for an ARM board with an STM32 chip on it, and OpenOCD with a JTAG programmer to flash the program to the ARM chip from VS. I prefer the VS development IDE to Eclipse so I’m a lot more productive with that environment, and to me it just feels more of a pleasure to use (others MMV). But the one thing I miss is a GDB extension to VS to debug the program running on the Pi. I’m aware of VisualGDB but I get more fun by learning through doing these things myself.

    Thanks for the article.

  7. avrmp

    I did all that but I still have a problem.
    One thing that I’ve notice is that there is also another inside”c:\cygwin64\opt\crosstools\arm-unknown-linux-gnueabi\” which is called “\arm-unknown-linux-gnueabi\” and that folder also has a “bin” folder inside which contains the “g++.exe”, so I also added the path “c:\cygwin64\opt\crosstools\arm-unknown-linux-gnueabi\” which is called “\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\bin” and now when i type g++ in the terminal it does not give me an error but it still does not recognize g++-4 because there is no file with that name?!
    so how do we solve the issue?
    Thank you

Trackbacks for this post

  1. Windows+QEMUでRaspberry Piをエミュレートする |

Leave a Reply