Cross-compiling NDN projects for Raspberry Pi » History » Version 14
Wentao Shang, 03/06/2014 10:59 AM
1 | 1 | Wentao Shang | Cross-compiling NDN projects for Raspberry Pi |
---|---|---|---|
2 | ============================================= |
||
3 | |||
4 | 2 | Wentao Shang | 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](http://www.amazon.com/Linkers-Kaufmann-Software-Engineering-Programming/dp/1558604960/ref=sr_1_1?ie=UTF8&qid=1394130356&sr=8-1&keywords=linker+and+loader) |
5 | 3 | Wentao Shang | |
6 | 10 | Wentao Shang | Basic idea |
7 | 7 | Wentao Shang | ---------- |
8 | 1 | Wentao Shang | |
9 | 7 | Wentao Shang | 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. |
10 | |||
11 | Difference between "native compiling" and "cross compiling" |
||
12 | 9 | Wentao Shang | -------- |
13 | 7 | Wentao Shang | |
14 | 14 | Wentao Shang | 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). |
15 | 8 | Wentao Shang | |
16 | 10 | Wentao Shang | Raspberry Pi platform information |
17 | 1 | Wentao Shang | -------- |
18 | 10 | Wentao Shang | |
19 | 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. |
||
20 | |||
21 | 14 | Wentao Shang | Creating compiling tools for Raspberry Pi |
22 | 10 | Wentao Shang | -------- |
23 | |||
24 | 14 | Wentao Shang | To prepare a building environment, we need to get the gcc/g++ compiler tools that will generate binaries for the armhf platform. Raspbian already provided a set of compiling tools on their official [github](https://github.com/raspberrypi/tools). 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++ tool set. |