C is a natural choice to program in on the Raspberry Pi. It's very powerful, usable on virtually all hardware platforms and really similar to lots of other programming languages such as Java, PHP, C# and objective C. As popular programming languages go its as powerful as it gets, with only assembler beating it in terms of programming to the bare metal of a hardware platform.  Its also what Linux itself is written in.

The notes on this site are largely focused on programming in C and C++ and we typically do this running on the Raspbian operating system.  If you are a beginner don't worry about the distinction between C and C++ too much.  You can start programming in a C++ project just using C and move into using the more fancy C++ concepts later on – you don't have to choose one or the other at the outset.  Once you start using some of the higher level features of C++ you can cause problems by also using straight C, but by the time you are comfortable doing that you should have learnt enough about the language to avoid those sorts of issues so don't worry about it at the outset.

Getting Started On Your Raspberry Pi For C & C++ Programming

Here's our step by step guide to getting up and running for C development on a Raspberry Pi using an IDE (Integrated Development Environment) so you don't have to program using the Linux command line.

1) Download the Raspbian Wheezy SD card image from the Raspberry Pi website downloads page

2) Install it on a SD card using win32diskimager (if you are running Windows) or use the new noobs installer.

3) Boot your RPi, log in and start the GUI

4) Geany will already be installed.

5) If you want to control the IO pins of your Raspberry Pi install the bcm2835 library by Mike McCauley

5) Create a new Geany project

That's it, happy coding!

Programming Your Raspberry Pi From Windows

This is very much do-able and the best solution for this we've found is using NetBeans, see here.

How Do We Used To Do It (Before NetBeans – This section is here still just for archive reasons)?

[Update 2015-02: This section was written before the release of the Raspberry Pi 2, which makes programming in an IDE directly on the Raspberry Pi a more realistic proposition with the version 2 performance boost.  The method of programming mentioned here is still very useful though if you want to be able to edit your code from a powerful PC running Windows etc]

We work primarily on Windows and our ideal is to be able to program using a good Windows IDE (Integrated Development Environment application).  We do that to program all sorts of embedded micro controllers and other processor boards so for us its an obvious choice to make for programming on the RPi too.  However we've not yet found the perfect solution. You'll notice in this section of the site various different approaches are documented and this is simply us making notes as we've tried different things searching for an optimum solution and learning the hard way (for instance Linux heads in forums swearing QEMU is the way to go, but finding out after a day of banging our head against a wall its seriously flawed until someone uber expert creates a more powerful hardware file for it).

The main problem – the RPi is amazing but its slow for an IDE and efficient fast desktop workers.  Sure you can program on the command line (and you'll find plenty of Linux heads telling you its best) but like marmite only certain people can bear to program in such a confined way and its definitely not for us. If you are new to programming then using Geany on the RPi is a brilliant way to get going creating a single file program or a multiple file program using a makefile like the one on this page. Once you get into programming large projects the sluggishness of the RPi platform is likely going to annoy you though. Its not just that the basic text editor in Geany is sluggish, its that you are likely also switching between Geany and web pages, pdf's, etc and having to wait for the OS to catch up all the time can be a massive pain.

This is how we've dealt with it for now (we keep looking for new better ways):

For projects that are using standard C libraries and simple to copy over RPi libraries we use eclipse on Windows with a cross compiler solution as documented here.

When we're programming applications using libraries with a lot of dependencies (e.g. GTK+), or if working on a PC where we don't want to go through the arduous process of setting up eclipse for windows cross compiler  programming we do the following to do "sort of" windows programming with eclipse!

We setup a network file share on the RPi using SMB as documented here. This lets us access the RPi via windows networking (it becomes a network device in Windows explorer)

We create a project in Geany on the RPi (various .c and .h files with the makefile on this page.

We then close Geany and run Eclipse on Windows.  We open the RPi .c and .h files in eclipse via the network drive and use eclipse to write our code.

We save the files using CTRL+SHIFT+S for save all and then we build the project from the RPi command line, or using LX Terminal if we're using the desktop, by moving to the project directory (e.g. cd projects/my_project/ ) and entering:


The results of the make are shown and if there are errors we have to reference them by line number in the files (eclipse show line numbers option is in: Menu > preference > general > editors > text editors > show line numbers).

Once we have a successful build we run the application on the RPi from the command line or LX Terminal using

sudo ./my_application.a

Its not ideal as the compiler is slower running on the RPi, we can't just double click on errors to be taken to the offending line in our code and we can't debug by stepping through the code, but the benefit of programming in a fast editor on a fast PC and getting to use the PRi with its amazing capabilities from the Linux OS and libraries makes this a pretty good compromise solution a lot of the time.



We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.