我已经搜索了这个问题,一些答案表明WSL 2现在支持ELF 32程序。
但是,未通过关于wsl2 Debian / Ubuntu发行版的简单测试。
这是我的考试:
// install run-time
sudo dpkg --add-architecture i386
sudo apt-get update
// install build tools
sudo apt install build-essential
sudo apt install gcc-multilib
// build
gcc helloworld.c -m32
// run!
./a.out
bash: ./a.out: cannot execute binary file: Exec format error
引用:
https://stackoverflow.com/questions/42120938/exec-format-error-32-bit-executable-windows-subsystem-for-linux
https://superuser.com/questions/1407730/run-32-bit-application-on-ubuntu-on-windows-subsystem-for-linux/1407818#1407818
答案 0 :(得分:1)
如果在WSL中运行命令uname -a
,则应获得包含WSL版本的结果。这应该类似于Linux COMPUTER_NAME 4.4.0-18362-Microsoft ...
。该输出中的数字18362是您的WSL版本,并且必须至少为19041才能成为WSL2版本(仅WSL2支持32位应用程序)。
您还可以在CMD Shell中运行wsl --list --verbose
,您将看到WSL实例的版本为1
。
WSL2将于2020年5月12日作为Windows 10 2004的一部分发布。如果您不想等待,可以通过“ Windows Insider计划”注册预览版本。
在Windows中转到设置-> Windows Insider程序并注册该程序。然后去检查更新。下载需要一段时间,然后按照提示进行所有重新启动等操作。
确保在打开或关闭Windows功能
wsl --set-default-version 2
,以使将来的所有WSL安装都使用WSL2 wsl --set-version <Distro> 2
将已安装的实例更改为WSL2
wsl --list --verbose
我在过去的一个小时中做了所有这一切,因为我需要运行今天早上构建的Zephyr模拟二进制文件。它奏效了,我很高兴:)