TransWikia.com

Run 32-bit application on Ubuntu on Windows subsystem for Linux

Super User Asked on October 27, 2020

I have a pretty simple application that was compiled with g++ -m32 flags.

Unfortunately, when I try to run it I am getting error:

bash: ./a.out: cannot execute binary file: Exec format error

If compiled without -m32 there is no error and it runs as expected.

What can be a problem and is it possible to solve it?

EDIT:

  1. Compiling with g++ -m32 --static doesn’t solve the issue.
  2. Setup is Ubuntu sub-system on Windows 10.

One Answer

You simply can't do that. WSL doesn't support 32-bit apps!

Most (if not all) Intel and AMD CPUs in the last decade support the x86_64 instruction set and there's no reason for Microsoft to spend time and money on supporting a 32-bit version of Linux. Most developers and Ubuntu users are running the 64-bit version anyway

No, we don’t support x86 32-bit at this time: We currently depend on x64-only instructions and mechanisms to ensure fast & stable performance.

Bash on Ubuntu on Windows


Update:

WSL2 runs in a real virtual machine using a real Linux kernel, so it's actually possible to do anything a Linux VM can do, including running 32-bit code. Just install 32-bit libs by running

sudo dpkg --add-architecture i386
sudo apt-get update

But again, you should really opt for the 64-bit version, especially if you have the source code. 32-bit Linux is much less maintained than the 64-bit version, since there are far fewer 32-bit only hardware in the last decade along with a significantly less number of users and testers. One example is that the Meltdown/Spectre patch for 32-bit Linux came out more than half a year later than the 64-bit version, and it's still buggy for years later

Correct answer by phuclv on October 27, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP