raspberry:raspberry-cross-platform
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| raspberry:raspberry-cross-platform [2024/04/28 12:39] – [GCC and Linux Architectures] oscar | raspberry:raspberry-cross-platform [2024/09/15 07:12] (current) – [Cross Platform Development for Raspberry] oscar | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Cross Platform Development for Raspberry ====== | ====== Cross Platform Development for Raspberry ====== | ||
| - | Cross-development means developing and compiling programs on another platform then it intended to run upon. It is a common approach for Pi, since it’s also how Raspian is built. For quite some time I did compile Pi applications on the Pi itself. Which works quite well, but has one large drawback: performance. Being able to compile these programs on my 8 core 16GB desktop, improved compilation time enorms. And it is quite simple. Let's have a look! | + | Cross-development means developing and compiling programs on another platform then it intended to run upon. It is a common approach for Pi, since it’s also how Raspian is built. For quite some time I did compile Pi applications on the Pi itself. Which works quite well, but has one large drawback: performance. Being able to compile these programs on my 8 core 16GB desktop, improved compilation time enorms. And it is quite simple. |
| + | - Manual setup **<- Used by me** | ||
| + | - Debian Crossbuild packages | ||
| + | Let's have a look! | ||
| ===== GCC and Linux Architectures ===== | ===== GCC and Linux Architectures ===== | ||
| GCC is also used to cross compile Linux applications. Applications can be compiled for 32-bit or 64-bit Linux systems. | GCC is also used to cross compile Linux applications. Applications can be compiled for 32-bit or 64-bit Linux systems. | ||
| Line 9: | Line 13: | ||
| * aarch64-linux-gnu-gcc and | * aarch64-linux-gnu-gcc and | ||
| * aarch64-linux-gnu-g++. | * aarch64-linux-gnu-g++. | ||
| - | |||
| Check the current target architecture by logging into the Pi: | Check the current target architecture by logging into the Pi: | ||
| < | < | ||
| Line 17: | Line 20: | ||
| </ | </ | ||
| - | ===== Set Up Cross Build Tools ===== | + | ===== Method 1: Debian Crossbuild packages |
| - | I’m using Ubuntu 16.04 on my desktop, but this should work with all Debian derivatives. Be carefull with older distribution since the ARM development libraries may not be the ones used on the Pi. The first step is to install the development | + | ==== Required Development sources |
| + | Install all the required build tools: | ||
| < | < | ||
| + | # apt-get update | ||
| + | # apt-get upgrade | ||
| + | # apt-get install crossbuild-essential-armhf | ||
| + | </ | ||
| + | Setup dpkg for armhf architecture: | ||
| + | dpkg --add-architecture armhf | ||
| + | apt-get update | ||
| + | Installing the development libraries for new arhitecture: | ||
| + | apt-get install libssl-dev: | ||
| + | apt-get install gnutls-dev: | ||
| + | apt-get install libmicrohttpd-dev: | ||
| + | apt-get install libgpiod-dev: | ||
| + | ===== Method 2: Manual Setup ===== | ||
| + | ==== Set Up Cross Build Tools ==== | ||
| + | The first step is to install the development tools on the desktop, or host system. From the command line run the following: | ||
| + | < | ||
| # apt-get update | # apt-get update | ||
| # apt-get upgrade | # apt-get upgrade | ||
| Line 28: | Line 48: | ||
| # apt-get install g++-aarch64-linux-gnu | # apt-get install g++-aarch64-linux-gnu | ||
| </ | </ | ||
| - | The first line makes sure that the system is up to date. The second instruction installs the general build tools. The third installs the C and C++ compiler and build tools for the Pi’s ARM processor. The ARM architecture designation, | + | The first line makes sure that the system is up to date. The second instruction installs the general build tools. The third installs the C and C++ compiler and build tools for the Pi’s ARM processor. The ARM architecture designation, |
| < | < | ||
| arm-linux-gnueabihf-g++ -v | arm-linux-gnueabihf-g++ -v | ||
| </ | </ | ||
| - | ===== Get required ARM libraries | + | ==== Get required ARM libraries ==== |
| Depending on the application and required libraries, it is possible that not all libraries are available. Easiest way is to copy these over from an existing Raspberry installation. | Depending on the application and required libraries, it is possible that not all libraries are available. Easiest way is to copy these over from an existing Raspberry installation. | ||
| On the Raspberry these are available in: // | On the Raspberry these are available in: // | ||
| Line 45: | Line 65: | ||
| ldconfig | ldconfig | ||
| </ | </ | ||
| - | ===== Test Application | + | ==== Test Application ==== |
| The host system should now be ready to build a Raspberry Pi program. Let’s test it with a minimal test application, | The host system should now be ready to build a Raspberry Pi program. Let’s test it with a minimal test application, | ||
| Line 75: | Line 95: | ||
| That's all. I told you this was simple. | That's all. I told you this was simple. | ||
| - | ====== Remote Debugging | + | ===== Remote Debugging ===== |
| We will gdb on host and Pi to debug with the GCC toolset. First install the debug capability on our desktop system that works with target systems regardless of the processor architecture. | We will gdb on host and Pi to debug with the GCC toolset. First install the debug capability on our desktop system that works with target systems regardless of the processor architecture. | ||
| < | < | ||
| Line 120: | Line 140: | ||
| The debugger provides a large number of commands for manipulating breakpoints, | The debugger provides a large number of commands for manipulating breakpoints, | ||
| - | |||
| - | |||
| - | |||
| - | ====== NEW ====== | ||
| ====== Links ====== | ====== Links ====== | ||
| Line 133: | Line 149: | ||
| * https:// | * https:// | ||
| * https:// | * https:// | ||
| - | |||
| - | $ sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | ||
raspberry/raspberry-cross-platform.1714307997.txt.gz · Last modified: by oscar
