快速搭建mips环境

系统环境为Ubuntu16.04,软件源为阿里云

0x01 安装qemu、libguestfs

sudo apt-get update
sudo apt-get install qemu libguestfs-tools

0x02 安装mips交叉编译

sudo apt-get install emdebian-archive-keyring 
sudo apt-get install linux-libc-dev-mips-cross 
sudo apt-get install libc6-mips-cross libc6-dev-mips-cross 
sudo apt-get install binutils-mips-linux-gnu gcc-mips-linux-gnu 
sudo apt-get install g++-mips-linux-gnu

此交叉编译工具应该已经完成了,可以测试一下

best@E4x:~/mips$ mips-linux-gnu-gcc --version
mips-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

但是实际运行时却报错⬇️

best@E4x:~/mips$ qemu-mips ./mips_test 
/lib/ld.so.1: No such file or directory

查资料后发现这个交叉编译工具默认会到/lib目录下找ld和libc,添加软链接到/usr/mips-linux-gnu/lib/目录下可解决

 sudo ln -s /usr/mips-linux-gnu/lib/ld.so.1 /lib/ld.so.1
 sudo ln -s /usr/mips-linux-gnu/lib/libc.so.6 /lib/libc.so.6

最后测试可以运行

best@E4x:~/mips$ file mips_test 
mips_test: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld., for GNU/Linux 3.2.0, BuildID[sha1]=90ec348a4bff3e0e9d2a20cb3b68aa3ed5dbb6d7, not stripped
best@E4x:~/mips$ qemu-mips ./mips_test 
Hello Mips
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1、交叉编译 由于嵌入式系统资源匮乏,一般不能像 PC 一样安装本地编译器和调试器,不能在本地编写、编译和调...
    不配野心阅读 2,154评论 0 4
  • Finally,I got it!首先,查资料自觉用google。恕我直言,除google外,其他的都是垃圾! 参...
    athorn阅读 29,158评论 1 10
  • note:高中随笔 充满了高中的无病呻吟,充满了当年对”他人即地狱“的智障理解;但是同时充满了我现在不敢想象的丰沛...
    Luinince阅读 285评论 1 5
  • 丰盛日记: 我要学会掌控自己的情绪,体察他人的情绪。我要让生活充满幸福和快乐。 我丰盛,拥有一颗感恩的心,善良的心...
    扎木年阅读 155评论 0 0
  • 女人心,海底针,以前不信,现在我信了。 远的不说了,就说说我身边的这几位吧! 你真的是我亲嫂子吗? 妈,你怎么不去...
    捞友君阅读 478评论 2 7