After installing the OPENWRT system on the router, it is necessary to cross-compile the binary program of the MIPS architecture on the host machine and then copy to the router to run the program.
1. Build a cross-compilation environment
Cross-compilation requires a cross-compilation toolchain when compiling OpenWrt. Cross-compiling toolchain and builds, we just need to add the path to the system environment variable.
exportstaging_dir=/path/to/openwrt/trunk/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uclibc-0.9.33.2 / exportpath= $PATH: $STAGING _dir/bin
where staging_dir each person's path is not the same, need to change according to their own circumstances.
2. Hello Word Program
Create a new test.c file, add
#include <stdio.h>voidmain () { printf ("Hello world\n"); return;}
In the terminal, enter the compile command:
./MIPSEL-OPENWRT-LINUX-GCC Test.c-o Test
Finally generate test program, through SCP or other means to copy to the router, run on the router, output
[Email protected]:~#./testhello World
Openwrt Cross-compiling Helloword