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