Tuesday, March 29, 2016

Cross Compiling - Compile C Programs on Your Windows Machine for a Raspberry Pi - Pi Setup

This is Part 3 of the tutorial on compiling C/C++ programs for Raspberry Pi on Windows

This tutorial will set up the Raspberry Pi.  The latest version of the operating system used is Raspbian Jessie, using other OSes may change how you need to do things.

Let's look at our model again from Part 1:

We'll need the Pi to be communicating with our PC to do two things:
  1. A (probably one-time) copy of the library files the Pi uses to link in additional functionality. Using library files may be familiar from using Arduino. Instead of picking one or more libraries to use, we'll copy all the library files on the PC as space is not much of a concern on a PC file system and it isn't that large (hundreds of megabytes).
  2. We need a mechanism to copy the finished executable file from our PC to the Raspberry Pi.

Your Pi and its Rasbian Operating System

If you are starting fresh (you do not have an operating system SD card), I suggest following instructions on downloading and placing the OS image on a SD (or microSD) card. Tutorials:
Insert the card into the Raspberry Pi. Boot your Pi with a keyboard, monitor, and network connection. If you need to connect to your Pi via your PC (sometimes called running headless), I suggest running the Adafruit utility Pi Finder.
This program has several advantages:
  • You can click the Terminal button to get a command line window access to the Pi
  • The Upload button will very quickly upload files to your Pi (perfect for compiled executables!)
  • Shut down your pi the correct way

Ensure a Fresh OS

To be sure we're running the newest operating system patches (which include possible library changes), we need to freshen things up. 

Configure your Pi:
  • via the command line, use guide here
  • via the graphical interface at Menu Button -> Preferences -> Raspberry Pi Configuration
  • Allow Secure Shell (SSH) connections during configuration.
For configuration be sure to select your locale and keyboard to match where you are and what you have. Setting the time zone is good as well as expanding your file system if your card is larger than 4 GB.

Now to update your Pi's software:
  • If you're in the graphical environment, click the computer screen icon to get a command line terminal
  • upgrade your software via this Raspberry Pi Tutorial
Now everything is (hopefully) running the latest Raspbian Jessie with all updates. We can now get the compiler loaded with all the libraries on your Pi!

Other blog posts in this series:

  1. Introduction
  2. PC Setup
  3. Pi Setup
  4. Library Setup
  5. Use



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.