假设有一个新的Ubuntu WSL实例,则需要安装qemu-user-static软件包,添加i386 binfmt,启用i386体系结构,更新软件包列表,并安装一些i386软件包:
安装qemu和binfmt
sudo apt update sudo apt install qemu-user-static sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic 'x7fELFx01x01x01x03x00x00x00x00x00x00x00x00x03x00x03x00x01x00x00x00' --mask 'xffxffxffxffxffxffxffxfcxffxffxffxffxffxffxffxffxf8xffxffxffxffxffxffxff'
需要更新软件包列表,已添加
sudo apt update
这将通过使它们通过qemu-i386-static执行来激活i386支持,并将配置文件放入其中/var/lib/binfmts/
以供将来重新激活。
每次重新启动WSL并需要i386支持时,都需要重新激活此功能:
sudo service binfmt-support start
启用i386架构和软件包
sudo dpkg --add-architecture i386 sudo apt update sudo apt install gcc:i386