How to cross-compile native C++ executable for Teltonika RUTX10 / RUTX11

First, download the pre-configure OpenWRT buildroot from Teltonika.

Unzip it:

tar xzvf RUTX_R_GPL_00.07.04.1.tar.gz
cd rutos-ipq40xx-rutx-gpl/

and now build using

./scripts/feeds update -a
make -i

This will build not only the toolchain but also all packages etc, hence it will take a while.

Now create main.cpp, e.g.:

#include <iostream>

int main(int argc, char** argv) {
    std::cout << "Hello World!" <<std::endl;
}

The build script build.sh looks like this:

#!/bin/sh
export STAGING_DIR=~/rutos-ipq40xx-rutx-gpl/staging_dir
export TOOLCHAIN=${STAGING_DIR}/toolchain-arm_cortex-a7+neon-vfpv4_gcc-8.4.0_musl_eabi
export CC=${TOOLCHAIN}/bin/arm-openwrt-linux-muslgnueabi-gcc
export CPP=${TOOLCHAIN}/bin/arm-openwrt-linux-muslgnueabi-g++

# Build !
${CPP} -o main main.cpp

This will produce main , an executable which you can copy to and run on your RUTX10.