####有时候,想简单编译些小程序,用openwrt的框架反而会不方便(主要是写那个Makefile不太方便)。其实方法很简单,我们需要找到openwrt下MT7688的编译器即可。
-
假设openwrt目录是在用户文件夹的根目录,则绝对目录大致是/home/mango/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin
-
修改用户目录的".bashrc"文件,在末尾位置添加一句:
export PATH=$PATH:/home/mango/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin
export STAGING_DIR=/home/mango/openwrt/staging_dir/ -
保存,使.bashrc有效:
source .bashrc
- 接下来终端里输入mipsel-openwrt-linux-gcc会出现:
mango@Ubuntu1404:~$ mipsel-openwrt-linux-gcc
mipsel-openwrt-linux-gcc: fatal error: no input files
compilation terminated.
mango@Ubuntu1404:~$
- 写一个经典的hello程序,并编译它
#include <stdio.h>
int main(void)
{
printf("hello widora!");
}
mipsel-openwrt-linux-gcc main.c
会在本目录生成a.out
- 用scp方法拷贝到widora上,增加可执行权限,并执行
mango@Ubuntu1404:~$ scp a.out root@192.168.1.1:/root
在widora上找到文件并执行
root@Widora:~# chmod +x a.out
root@Widora:~# ./a.out
hello widora!