Tuesday, March 29, 2016

Cross Compiling - Compile C Programs on Your Windows Machine for a Raspberry Pi - Library File Copy

This Part 4 of the posts on cross compiling Raspberry Pi programs on your PC.

From previous posts, we have the gcc cross compiler on the PC and a fresh Raspbian Jessie running on the Pi. The next step is to get the latest library files from the Pi over to the PC.

Fortunately those charitable folks at sysprogs have another utility to pull the correct files from your Pi to your PC.  If you installed gcc into C:\SysGCC (or substitute your own directory path), go to C:\SysGCC\TOOLS in Windows File Explorer.  Run UpdateSysroot.bat by double clicking it.  You'll get the pop-up window below:

Type in the IP address of your Pi. In the Adafruit Pi Finder, it gives you the address as 4 numbers separated by periods.You can run sudo ifconfig in a Pi terminal window to find the 4 number group IP address. Look at eth0 for wired connection, wlan0 for wireless.

Leave the other settings on their default values and press the Synchronize button. This will take several minutes and takes a few hundred megabytes of hard disk space on your PC.

Once the process is done, our setup is finally complete!  It would be a longer setup if we would have set up a full compile environment. The next post demonstrates compiling a program and using it on your Pi.

Other blog posts in this series:
  1. Introduction
  2. PC Setup
  3. Pi Setup
  4. Library Setup (this page)
  5. Use