OpenWrt mips交叉编译链配置mt7688

 

mt7688是mips架构,交叉编译工具是 mipsel-openwrt-linux-g++  mipsel-openwrt-linux-gcc

 

交叉编译链在 staging_dir目录/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin$

 

在图片上可以看到很多mips-gcc的各种工具比如mips-openwrt-linux-gcc是gcc编译器

mips-openwrt-linux-gdb 是调试器,

mips-openwrt-linux-g++是C++编译器,

让交叉编译连接全局可用

只需要将编译连接的相关路径加到/etc/bash.bashrc,如下图

sudo  vi /etc/bashh.bashrc

最后添加

export PATH=$PATH:~/openwrt/openwrt-hiwooya-stable/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/

注意具体路径需要根据你自己环境修改

保存退出,执行更新配置命令,source  /etc/bashh.bashhrc

测试下是否有效,vi输入mips-+TAB键 自动补全,说明配置生效了。

接下来就可以用C语言写一个helloworld 测试程序了

river@pc:~/openwrt/helloworld$ mipsel-openwrt-linux-g++ helloworld.c  -o helloworld

mipsel-openwrt-linux-g++: warning: environment variable 'STAGING_DIR' not defined

warning: environment variable 'STAGING_DIR' not defined  

警告说是找不到STAING_DIR,这个环境变量 只需要在/etc/bash.bashrc 文件中添加上这句即可

export STAGING_DIR=$STAGING_DIR:~/openwrt/openwrt-hiwooya-stable/staging_dir/

保存退出,执行更新配置命令,source  /etc/bashh.bashhrc

注意具体路径需要根据你自己环境修改

 

file可以查看 生成文件的格式

file  helloworld

river@pc:~/openwrt/helloworld$ file helloworld

helloworld: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked, interpreter /lib/ld-, not stripped

 

可以看到该执行文件为ELF格式mips架构的32位平台程序。

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值