I have googled this problem, some answers declared that WSL 2 now supports ELF 32 program.
However, a simple test on wsl2 Debian/Ubuntu distro was not passed.
Here is my test:
// 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
refers:
If you run the command uname -a
in WSL you should get a result that contains the version of your WSL. This should be something like Linux COMPUTER_NAME 4.4.0-18362-Microsoft ...
. the number 18362 in that output is your WSL version and it needs to be at least 19041 to be a WSL2 build (only WSL2 supports 32-bit apps).
You could also run wsl --list --verbose
in a CMD shell and you will see the version of your WSL instance is 1
.
WSL2 will be released as part of Windows 10 2004 on May 12, 2020. If you don't want to wait you can sign up for the preview builds through the "Windows Insider Program".
In Windows go to Settings -> Windows Insider Program and register for the program. Then go check for updates. It will take a while to download, then follow the prompts to do all the restarts, etc required.
Ensure "Virtual Machine Platform" is enabled in Turn Windows Features On or Off
wsl --set-default-version 2
to make all future WSL installs use WSL2wsl --set-version <Distro> 2
to change an already installed instance to WSL2
wsl --list --verbose
I just did all of this over the last hour, because I needed to run a Zephyr simulation binary I built this morning. It worked, and I am very happy :)