How to compile with the openwrt toolchain

From WRTnode Wiki Site
Jump to: navigation, search
This page contains changes which are not marked for translation.

Other languages:
English 100% • ‎中文(中国大陆)‎ 100%

openwrt compile tool chain
Cross compiler tool chain is to compile, link, handling and debugging cross-platform architecture code.For cross-development tool chain, in the file name with a prefix to distinguish native tool chains.For example, mipsel-openwrt-linux representation is mipsel-openwrt cross compiler tool chain; mipsel-openwrt-linux-gcc representations are using gcc compiler. In addition to the architecture specific compiler options , its usage is the same with the linux , so Linux programming helpful for embedded linux.
So what is the difference between gcc and mipsel-openwrt-linux-gcc is it? Difference is gcc C language compiler under linux, compiled in the local implementation of the program, while openwrt-linux-gcc cross-platform C language compiler under linux, translation of the program on the target machine (eg openwrt platform) execution, embedded developers should use embedded cross compiler tool chain.
Download ready-compiler tool chain from openwrt official website。 Click here to download
Linux using wget:

wget https://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620n/OpenWrt-Toolchain-ramips-for-mipsel_24kec%2bdsp-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2

Then extract it to your working directory:

tar -xjf OpenWrt-Toolchain-ramips-for-mipsel_24kec+dsp-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2

Cross compiler tools we need in this directory `OpenWrt-Toolchain-ramips-for-mipsel_24kec + dsp-gcc-4.8-linaro_uClibc-0.9.33.2 / toolchain-mipsel_24kec + dsp_gcc-4.8-linaro_uClibc-0.9.33.2 / bin `
Common tools:
mipsel-openwrt-linux-gcc gcc compiler
mipsel-openwrt-linux-gdb debugger
mipsel-openwrt-linux-ld linker
mipsel-openwrt-linux-as Assembler
Use and the corresponding tool under linux same.
Here is an mipsel-openwrt-linux-gcc compiler small example helloworld

vi helloworld.c

Enter the following:

#include <stdio.h>
int main(void){
    printf("hello world!\n");
    return 0;
}

Then use mipsel-openwrt-linux-gcc to compile

mipsel-openwrt-linux-gcc helloworld.c -o helloworld

Then copy the file to your WRTnode development board, here we put to the /tmp directory

./tmp/helloworld

output

hello world!

Well, little program to here.