[Android] 單獨編譯生成boot.img時mkbootfs: No such file or directory解決方法
阿新 • • 發佈:2019-02-19
在一臺沒有安裝Android原始碼編譯環境的64位 Ubuntu14.04.5虛擬機器上嘗試單獨編譯Android用的Linux Kernel。並從編譯好Android原始碼的機器上將out資料夾下的mkbootfs、minigzip、mkbootimg二進位制程式copy了過來,用於生成boot.img
用copy過來的arm-eabi-4.6編譯Kernel正常,但是編譯後生成ramdisk.img的那一步,指令碼執行總提示
tools/mkbootfs: No such file or directory
tools/minigzip: No such file or directory
確認了mkbootfs和minigzip檔案的許可權等沒發現問題,只能想到是某些安裝包沒有安導致與原有的開發環境不一樣。
試驗後用下面命令安裝g++-multilib和gcc-multilib後就正常了。
sudo apt-get install g++-multilib gcc-multilib
果然是由於mkbootfs是用32位的gcc/g++編譯生成的,所以在64位系統上執行就需要安裝g++-multilib或者gcc-multilib,兩個只安裝其中一個可能也可行,不過以後可能還有其他需要,就索性都安上吧。
又用readelf確認了一下mkbootfs檔案的ELF Header證實了想法。
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x8048c28
Start of program headers: 52 (bytes into file)
Start of section headers: 23604 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 39
Section header string table index: 36