Page 1 of 1

What to install under Ubuntu to cross-compile for a Pi4 running Raspbian "buster"?

Posted: Mon Jan 13, 2020 10:00 pm
by fgfanta
I would like to build the source code on a PC running Ubuntu 18.04, to then deploy the executable to a Pi4 model B running Raspbian/Debian 10 "buster".

What should I install on the Ubuntu PC in order to do this? I expect I must install gcc and c++ compilers for ARM and some libraries, but I don't know what are the correct packages to be installed.

Re: What to install under Ubuntu to cross-compile for a Pi4 running Raspbian "buster"?

Posted: Tue Jan 14, 2020 12:16 pm
by topguy
There are many many guides for cross compiling and everyone does it slightly different.

Simplest one: https://hackaday.com/2016/02/03/code-cr ... pberry-pi/
But this does not give you access to any Raspbian libraries/header, only standard C/C++, but installs compilers from repo.

Another example here: https://mechatronicsblog.com/cross-comp ... pberry-pi/

You should only focus on step 3 (toolchain) and 4 (libraries) and you need to understand the link between step 1 and 4.
This guide prefers to just download the tools into a folder instead of installing packages, so you have to tell your IDE or makefile system to use those tools there instead of the system compilers. And you need to tell the compiler to use the Raspbian libraries in the "sysroot".

There are also ways of creating the sysroot from a Raspbian imagefile instead of copying it from a running Pi.

Re: What to install under Ubuntu to cross-compile for a Pi4 running Raspbian "buster"?

Posted: Wed Jan 22, 2020 2:29 am
by xthenode
I just build on the pi itself...
no xcompiling necessary...
make sure the heat sink is installed when compiling...