windows下用WSL運行32位程序會報錯:
aapt: cannot execute binary file: Exec format errorgit
file aapt #查看文件信息
aapt: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.24github
github上@Froosh給出了他的解決方案,經過安裝qemu來運行32位的程序shell
sudo apt update sudo apt install qemu-user-static sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
這一步實現了把程序的運行交由qemu-user-static來運行,從而實現運行32位vim
注意每次重啓WSL都得從新開啓,可將這步加到開機自動啓動中windows
sudo service binfmt-support start
vim /etc/myinit.sh
sudo service binfmt-support start
Set ws = WScript.CreateObject("WScript.Shell") cmd = "C:\Windows\System32\bash.exe -c ""bash /etc/myinit.sh""" ' 運行命令不顯示cmd窗口 ws.Run cmd, 0, false Set ws = Nothing WScript.quit
搞定。bash
參考:
https://github.com/Microsoft/WSL/issues/2468
https://blog.csdn.net/fcymk2/article/details/79711566ui