DEV Community

Kai Sasaki
Kai Sasaki

Posted on

How to achieve ARM cross-compilation on macOS

This article originally comes from lewuathe.com. Please visit there too if you find this interesting.

Cross-compilation is occasionally troublesome. It often requires us to install additional toolchain to get it done.

Now, I found I needed to compile my source code for the Arm architecture machine for Mbed application. I do not have any idea how to install the toolchain for Arm compilation. Thus this is the post to describe the fastest way to prepare the toolchain for the cross-compilation for Arm.

Xcode Compiler

Please ensure to install Xcode first. Xcode contains the first compiler sets, such as clang.

$ xcode-select --install

Arm Toolchains from Homebrew

You can install Arm GCC toolchains by using Homebrew. There are two options.

There is no difference between these two distributions. They use precisely the same package internally. You can use whichever you want.
For my Mbed application, I choose the second one.

$ brew tap ArmMbed/homebrew-formulae
$ brew install arm-none-eabi-gcc

You should be able to find the compiler eventually. The following tools are installed in the local machine.

$ arm-none-eabi-gcc
$ arm-none-eabi-g++
...

It looks like they are GCC for Arm architecture. I believe it is the easiest way to prepare the Arm build toolchains in macOS platform.

Thanks

Top comments (0)