Installing Native Toolchain

This page shows you how to install the toolchain to build Mynewt OS applications that run native on macOS and Linux. The applications run on Mynewt’s simulated hardware. It also allows you to run the test suites for all packages that do not require HW support.

Note: This is not supported on Windows.

Setting Up the Toolchain for Mac

Installing Brew

If you have not already installed Homebrew from the newt tutorials pages install it (Installing Newt on macOS).

Installing GCC/libc

Since macOS with Xcode ships with a C compiler called Clang there is no need to install the other compiler. However, one can install gcc compiler with brew:

$ brew install gcc
==> Pouring gcc-10.2.0_2.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/gcc/10.2.0_2: 1,455 files, 338.1MB

Check the GCC version you have installed (either using brew or previously installed). The brew-installed version can be checked using brew list gcc. To use gcc instead of clang <mynewt-src-directory>/repos/apache-mynewt-core/compiler/sim/compiler.yml file must be edited:

# OS X. "gcc" "gcc"
compiler.path.objdump.DARWIN.OVERWRITE: "gobjdump"
compiler.path.objcopy.DARWIN.OVERWRITE: "gobjcopy"
compiler.flags.base.DARWIN: [-DMN_OSX, -Wno-missing-braces]
compiler.ld.resolve_circular_deps.DARWIN.OVERWRITE: false

…with the following: "gcc-<version>" "gcc-<version>”

Installing GDB

$ brew install gdb
==> Summary
🍺  /usr/local/Cellar/gdb/7.10.1: XXX files,YYM

NOTE: When running a program with GDB, you may need to sign your gdb executable. This page shows a recipe for gdb signing. Alternately you can skip this step and continue without the ability to debug your mynewt application on your PC.*

Setting Up the Toolchain for Linux

The below procedure can be used to set up a Debian-based Linux system (e.g., Ubuntu). If you are running a different Linux distribution, you will need to substitute invocations of apt-get in the below steps with the package manager that your distro uses.

Installing GCC/libc that will produce 32-bit executables

$ sudo apt-get install gcc-multilib libc6-i386

Installing GDB

$ sudo apt-get install gdb

Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  gdb-doc gdbserver
The following NEW packages will be installed:
Processing triggers for man-db ( ...
Setting up gdb (7.7.1-0ubuntu5~14.04.2) ...