Cross compile beginning without Makefile

For building a cross compiling system for my router Newifi D1(2nd Generation), I tried crosstools-ng.

In Ubuntu 18.04, because of the version of perl, the environment cannot be built correctly with ct-ng build after the configuration.

I will not talk about the error here. In fact, the error has been fixed in the pull request Pull 1043.As the latest version is crosstool-ng-1.23.0 released at Apr 20, 2017. We can do nothing except waiting (although we can build the tool manually, it’s better to wait for an officiel release).

We come back for the theme.

The CPU of my router is mt7621a, and the system is based on openwrt Barrier Breaker. The architecture of this CPU is mipsel 32.

We can download openwrt toolchain for mipsel and decompress it.

The compiler is based on toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin.

To test, we create a simple hello world:

1
2
3
4
5
6
7
#include <stdio.h>

int main()
{
printf("Hello World\n");
return 0;
}

Compile it:

1
toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc helloworld.c -o helloworld

Upload it:

1
scp helloworld [email protected]:/

We connect to the router with ssh and test it:

1
2
>./hello
Hello World

It works!
There will be a tutorial more advanced in some days.