打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
交叉编译斐讯全系列产品的应用程序 | 技术小站

1、根据你目前系统安装依赖库
centos 6 64位系统下的依赖库:
yum install -y subversion binutils bzip2 gcc gcc-c++ gawk gettext flex xz time
yum install -y ncurses-devel zlib-devel make patch unzip perl-ExtUtils-MakeMaker
yum install -y glibc glibc-devel glibc-static quilt ncurses-lib sed sdcc intltool sharutils bison wget

2、下载SDK
比如当前目录为root,下载sdk
ar71xx--K3C/K2T的SDK
wget http://archive.openwrt.org/chaos_calmer/15.05/ar71xx/generic/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2
tar xjf OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2

ramips--K2/K2P MTK的SDK:
wget http://archive.openwrt.org/chaos_calmer/15.05/ramips/mt7621/OpenWrt-SDK-15.05-ramips-mt7621_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2
tar xjf OpenWrt-SDK-15.05-ramips-mt7621_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2

arm--K3/K2P BCM的SDK:
wget http://archive.openwrt.org/chaos_calmer/15.05/bcm53xx/generic/OpenWrt-SDK-15.05-bcm53xx_gcc-4.8-linaro_uClibc-0.9.33.2_eabi.Linux-x86_64.tar.bz2
tar xjf OpenWrt-SDK-15.05-bcm53xx_gcc-4.8-linaro_uClibc-0.9.33.2_eabi.Linux-x86_64.tar.bz2

3、建立批处理编译文件
把如下内容保存为/root/cfx.sh,并赋予可执行权限

chmod 755 /root/cfx.sh

 
 
 
# ar71xx--K3C/K2T export STAGING_DIR=$STAGING_DIR:/root/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64 export PATH=$PATH:/root/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin # ramips--K2/K2P MTK   export STAGING_DIR=$STAGING_DIR:/root/OpenWrt-SDK-15.05-ramips-mt7621_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64 export PATH=$PATH:/root/OpenWrt-SDK-15.05-ramips-mt7621_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/toolchain-mipsel_1004kc+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin #arm--K3/K2P BCM export STAGING_DIR=$STAGING_DIR:/root/OpenWrt-SDK-15.05-bcm53xx_gcc-4.8-linaro_uClibc-0.9.33.2_eabi.Linux-x86_64 export PATH=$PATH:/root/OpenWrt-SDK-15.05-bcm53xx_gcc-4.8-linaro_uClibc-0.9.33.2_eabi.Linux-x86_64/staging_dir/toolchain-arm_cortex-a9_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin  mips-openwrt-linux-gcc   $1.c -o $1_mips mipsel-openwrt-linux-gcc $1.c -o $1_mipsel arm-openwrt-linux-gcc 	$1.c -o $1_arm

 

4、编译测试

新建一个文件,比如test.c

 
 
 
#include <stdio.h> int main(int argc, const char *argv[]) { printf("hello world \n"); return 0; }

执行如下语句编译:

./cfx.sh test

生成对应3个平台的3个可执行文件:

5、其他说明
如果要编译各个平台的已有组件,比如aria2,可以进入对应的SDK目录,然后
./scripts/feeds update
./scripts/feeds install aria2
./scripts/feeds install zlib
./scripts/feeds install openssl
make menuconfig
选中aria2,然后进行编译即可

如果要编译最新的18.06版本的,下载对应sdk解压即可,新sdk采用xz压缩,解压方式不同,比如K3的18.06版本的SDK:
wget http://downloads.openwrt.org/releases/18.06.1/targets/bcm53xx/generic/openwrt-sdk-18.06.1-bcm53xx_gcc-7.3.0_musl_eabi.Linux-x86_64.tar.xz
xz -d openwrt-sdk-18.06.1-bcm53xx_gcc-7.3.0_musl_eabi.Linux-x86_64.tar.xz
tar xf openwrt-sdk-18.06.1-bcm53xx_gcc-7.3.0_musl_eabi.Linux-x86_64.tar

新版使用了签名,如果编译最后提示key-build找不到,可以用下面两种方法解决:
方法1:
./staging_dir/host/bin/usign -G -s ./key-build -p ./key-build.pub -c "Local build key"
方法2:
make menuconfig
禁止 global building settings | Cryptographically sign package lists
  

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Openwrt 交叉编译(Crosscompile)及使用SDK生成ipk安装包
使用交叉编译编译在OpenWRT上运行的程序
openWrt软件开发教程1(交叉编译和ipk包生成)
Configuring Qt Creator for the Raspberry Pi
树莓派交叉编译环境搭建介绍(英文Blog转载)
ubuntu 海思SDK安装
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服