Skip to content

Cross-Compiling Ioto

Building Ioto for platform different to that of the local system is called cross compiling. Sometimes this compiling is just for a different instruction set (say x64 instead of x86). Other times, it is for a completely different operating system and/or CPU architecture. In such cases, a cross-compiler is typically required to build for the target platform.

To cross compile, you will typically need to install a cross-compiler tool chain for your target architecture. Once installed and before you attempt to build Ioto, it is best to test compiling a simple, stand-alone HelloWorld program to ensure the cross compiler is working correctly.

If you are targeting the popular ESP32 Architecture please read the dedicated instructions Building for ESP32.

If you are interested in porting Ioto to a new platform, please read Porting Ioto.

Invoking Make

To cross-compile Ioto, invoke the relevant project makefile and pass the required CPU architecture as a make variable. For example, to cross compile for VxWorks on ARM:

1
make -f projects/ioto-vxworks-default.mk ARCH=arm PROFILE=debug

When the project makefile is invoked directly, it will place the output products (executables, libraries and objects) in a platform-specific output directory. This is named using the form: OS-ARCH-PROFILE. For example: vxworks-arm-debug. In this manner, make can be invoked multiple times, once for each target platform and the results will be captured in separate platform output directories. Some of the supported architectures for the ARCH field are:

arm, arm64, mips, mips64, ppc, ppc64, riscv, riscv64, sh, sparc, x64, x86 and xtensa.

The PROFILE variable is a descriptive name chosen by you for your configuration.

If there is not a makefile for your target operating system, copy the closest makefile and edit to suit your target platform. The project makefiles are generated and are thus highly regular and easy to modify.

Specifying the CPU

The build will use the generic CPU type within the specified architecture. To override the default choice and specify a CPU type within an architecture, use the CPU variable. For example:

1
make OS=vxworks ARCH=arm CPU=arm7tdmi

Specifying a Tool Chain

You may need to specify where make can locate your cross-compiler and other tools. You can supply these via the make variables: CC, CFLAGS, DFLAGS, IFLAGS, LD and LDFLAGS. For example:

1
2
make CC=/opt/bin/ccarm.exe LD=/opt/bin/ccarm.exe ARCH=arm PROFILE=release \
    -f projects/ioto-vxworks-default.mk