I needed to compile an arm64 binary to run on the UniFi Dream Machine Pro. This is how I used docker to setup cross compilation tools and compile the binary on macOS.
Get and install Docker Desktop is not already installed. Once installed we can use DockCross to setup an cross compile tool chain we want. Here is an example of how I setup the linux-arm64 toolchain.
|
|
This will setup a linux-arm64 cross compiler. To compile files using this compiler you have to place the files in the same directory as the binary. Here is an exaple of how to compile.
|
|
Examining the compiled binary with file command should display ARM aarch64 architecture.
|
|
|
|
Note: Using $CC is important. If you use gcc directly it will compile using x86_64 version.