gccexecutablewindows-subsystem-for-linux32-bitexecutable-format

Exec format error 32-bit executable Windows Subsystem for Linux?


When I try to execute a 32-bit file compiled with gcc -m32 main.c -o main on Windows Subsystem for Linux, I get the following error: bash: ./main: cannot execute binary file: Exec format error.

If I compile it without -m32 it runs.

Any solution for running 32-bit executable on WSL?


Solution

  • 32-bit ELF support isn't provided by WSL (yet). There doesn't seem to be any progress since the UserVoice was raised - you are out luck.

    See UserVoice: Please add 32 bit ELF support to the kernel and Support for 32-bit i386 ELF binaries.

    If possible, switch to a real Linux ;-)


    Since this was originally posted, the support has been available on WSL2 which does support real Linux kernel! So that should be the preferred way.

    As noted in the linked github issue, there's also qemu-user which can be used if WSL1 is still used.