Hi ! In this Article i will explain how to setup a cross-compiling development environment for the Raspberry Pi.The aim of this
demonstration is compiling a program using the cross compiler and then deploy it onto a Raspberry Pi board to run it.
But Why Cross compiling?
“A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a Windows 7 PC but generates code that runs on Android smartphone is a cross compiler.”
So for the explanation we will use :
- A cloud based Ubuntu Server 14.04 LTS
- Raspberry Pi board
The Raspberry Pi is a series of credit card–sized single-board computers
First we need to Login to Ubuntu server via SSH
Getting Started: Install Dependencies
Now We must install a few packages:
APT-GET INSTALL This command installs new packages.
Create Development Directories
mkdir() attempts to create directories
Download, Build, and Install Crosstool-NG
pushd and popd are commands used to work with directories:
The pushd command saves the current working directory in memory
The popd command returns to the path at the top of the directory stack
Run ./configure Script
Make and make install Commands:
Makefiles are a simple way to organize code compilation
Export the environment variable $PATH
Kernel Configurations: (Target arch, compiler etc…)
Build the Kernel:
If you want to build it locally on a Raspberry Pi it will take a long time or you can cross-compile it (you need to wait just about 17 min) , which is much quicker.