openwrt 问题六 搭建自己的交叉编译环境

使用openwrt难免需要编译自己的c或者C++程序,所以我们需要搭建自己的交叉编译环境

 

(1)在生成Openwrt固件时,选择Buildthe OpenWrt based Toolchain和Build the OpenWrt SDK就可以生成相应的交叉编译器。如下图所示:


(2)找到trunk/bin/ramips/OpenWrt-Toolchain-ramips-for-mipsel_24kec+dsp-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2

并将其拷贝到交叉编译的机器上

(3)解压到某个目录,例如/usr/share/openwrt

tar xvfOpenWrt-Toolchain-ramips-for-mipsel_24kec+dsp-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2-C /usr/share/openwrt

(4)建立软链接,对应关系如下:

/usr/bin/mips-g++ ->/usr/share/openwrt/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/mipsel-openwrt-linux-g++

 

/usr/bin/mips-gcc ->/usr/share/openwrt/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/mipsel-openwrt-linux-gcc

 

/usr/bin/mips-strip ->/usr/share/openwrt/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/mipsel-openwrt-linux-strip

 

(5)找到

trunk/bin/ramips/OpenWrt-SDK-ramips-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2

 

(6)解压到某个目录,例如/home/huqian/build/OpenWrt-SDK-ramips-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2

/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2

并执行

exportSTAGING_DIR=/home/xxxx/build/OpenWrt-SDK-ramips-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2

 

接下来,就可以直接使用mips-g++/mips-gcc命令来编译可以在Openwrt上运行的程序。


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值