Tuesday, March 29, 2016

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

This is Part 2 of the series on cross compiling on the PC for the Raspberry Pi.

Let's set up a Windows computer to allow for Raspberry Pi cross compiling.

As stated in the original post, there are several ways to get a toolchain for cross compiling, often involving making your Windows PC more like a Linux/Unix machine. This involves more work than most people are looking for.

This effort leverages prior work to build the toolchain by sysprogs.com. They have posted a large number of cross compilers pre-built under the GNU license.

Download the latest toolchain for Raspbian Jessie (gcc 4.9.2 as of this tutorial). Run the program and you'll get the following screen:

Due to the Unix roots for cross compilers, you need to set an installation directory without spaces in any directory name.  This rules out the typical Windows Program Files directory.  I selected C:\SysGCC.

The installation takes several minutes, even on a fast PC as there are a large number of files involved. There will not be any icon for the desktop as the tools are for command line use.

That's it, your tools will be placed in the directory you specified.  Remember the location.

The cross compiler will not have the latest libraries for the Raspberry Pi that are included in the Raspbian Jessie distribution.  These are needed as they are linked in, used by the compiler to add pre-built functionality to a program at compile time. The easiest way to get a fresh set is to copy over the files from specific directories on an up to date Raspberry Pi.  This will be done in the next post.

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.