| 1 | # Linux cross-compilation |
| 2 | |
| 3 | @tableofcontents |
| 4 | |
| 5 | <!-- markdownlint-disable MD031 --> |
| 6 | @warning These instructions are no longer recommended because they involve disabling security measures |
| 7 | for the target system. Please try the [instructions using CMake](using_cmake.md). |
| 8 | |
| 9 | RF24 library supports cross-compilation. Advantages of cross-compilation: |
| 10 | |
| 11 | - development tools don't have to be installed on target machine |
| 12 | - resources of target machine don't have to be sufficient for compilation |
| 13 | - compilation time can be reduced for large projects |
| 14 | |
| 15 | Following prerequisites need to be assured: |
| 16 | |
| 17 | - ssh password-less access to target machine [Here is a hint](https://linuxconfig.org/passwordless-ssh) |
| 18 | - sudo of a remote user without password [Here is a hint](http://askubuntu.com/questions/334318/sudoers-file-enable-nopasswd-for-user-all-commands) |
| 19 | - cross-compilation toolchain for your target machine; for RPi |
| 20 | ```shell |
| 21 | git clone https://github.com/raspberrypi/tools rpi_tools |
| 22 | ``` |
| 23 | and cross-compilation tools must be in PATH, for example |
| 24 | ```shell |
| 25 | export PATH=$PATH:/your/dir/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin |
| 26 | ``` |
| 27 | |
| 28 | ## Cross compilation steps |
| 29 | |
| 30 | 1. clone RF24 to a machine for cross-compilation |
| 31 | ```shell |
| 32 | git clone https://github.com/nRF24/RF24 |
| 33 | cd RF24 |
| 34 | ``` |
| 35 | 2. configure for cross compilation |
| 36 | ```shell |
| 37 | ./configure --remote=pi@target_linux_host |
| 38 | ``` |
| 39 | eventually |
| 40 | ```shell |
| 41 | ./configure --remote=pi@target_linux_host --driver=<driver> |
| 42 | ``` |
| 43 | 3. build |
| 44 | ```shell |
| 45 | make |
| 46 | ``` |
| 47 | 4. (optional) install library to cross-compilation machine into cross-environment - important for compilation of examples |
| 48 | ```shell |
| 49 | sudo make install |
| 50 | ``` |
| 51 | 5. upload library to target machine |
| 52 | ```shell |
| 53 | make upload |
| 54 | ``` |
| 55 | 6. (optional) compile examples |
| 56 | ```shell |
| 57 | cd examples_linux |
| 58 | make |
| 59 | ``` |
| 60 | 7. (optional) upload examples to target machine |
| 61 | ```shell |
| 62 | make upload |
| 63 | ``` |