解決win10 WSL下cannot execute binary file: Exec format error

主要原因是不支持32位程序,可以用如下方法啓用:
WSL默認使用64bit的程序,不支持32位的程序,但我們仍然可以使用QEMU來虛擬化內核。
安裝QEMU

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'

啓動服務,注意每次調試32位程序之前都要啓用一次

sudo service binfmt-support start

啓用32位架構

sudo dpkg --add-architecture i386
sudo apt update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章