Cross-compiling NDN projects for Raspberry Pi » History » Revision 16
« Previous |
Revision 16/48
(diff)
| Next »
Wentao Shang, 03/06/2014 02:07 PM
Cross-compiling NDN projects for Raspberry Pi¶
Note: before reading this document, you should already be familiar with the basic concepts of compiling and linking (especially the linking part). If not, you may be interested in reading this great book: Linkers and Loaders
Basic idea¶
Remember to compile a C/C++ project, we need the source code for the project, the header files for the included libraries, the binary objects of the libraries, and the compiler tools (gcc, as, ld, etc.). The combination of the last three things together is referred to as a building environment. Cross-compiling is no different. To cross compile a project, we first need to setup the building environment and then build the source code in that environment.
Difference between "native compiling" and "cross compiling"¶
The biggest difference is that for native compiling, you build the binaries that will run on the same platform where you build them. For cross compiling, however, you build the binaries on one platform (called build platform) and run them on another platform (called host or target platform). The platforms may differ in the operating systems (Windows vs. Linux) and/or the CPU architectures (x86_64 vs. arm32).
Raspberry Pi platform information¶
Raspberry Pi runs on ARMv6 CPU, which is a 32bit chip with hardware float-point support (abbreviated as armhf). There are many operating systems available. The one we are going to use is called Raspbian, which is a port of the Debian "wheezy" Linux distribution.
Creating compiling toolchain for Raspberry Pi¶
To prepare a building environment, we need to get the gcc/g++ compiler toolchain that will generate binaries for the armhf platform. Raspbian already provided a set of compiling tools on their official github. However, by the time of this writing, those tools only run on 32bit Linux systems. If we want to use 64bit Linux as the build platform, we may need to build our own gcc/g++ toolchain.
The tool we are going to use to build our gcc is ct-ng. It is designed to run on Linux but can be adjusted via some hacks to run on MacOSX. It is pretty easy to use and you may find this article very helpful when building your own toolchain.
Tip: you may use the configuration file from Raspbian github, which will load the "official" configurations for the platform.
Getting libraries ready¶
Updated by Wentao Shang almost 11 years ago · 48 revisions