交叉编译斐讯全系列产品的应用程序
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
评论:2