Does WSL 2 really support 32 bit program?
Asked Answered
P

1

4

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:

Persecute answered 19/4, 2020 at 6:0 Comment(0)
J
10

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 part of the Windows update later this month

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".

Get WSL2 through Windows Insider Program now (about 1 hour of work):

  • 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

  • In CMD or powershell run wsl --set-default-version 2 to make all future WSL installs use WSL2
  • run wsl --set-version <Distro> 2 to change an already installed instance to WSL2
    • This will take a LONG time. I gave up after reading online that it could take hours. Instead I uninstalled Ubuntu and reinstalled it. That took about 10 minutes. As long as you set the default to WSL2, the re-install will be WSL2.
  • You can verify your WSL is now version 2 by running wsl --list --verbose
  • Your 32-bit binaries should now work

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 :)

Sources:

Github issue - scroll to end

Install WSL2

Jarrod answered 4/5, 2020 at 0:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.