Wine is a program to run Windows applications on a Unix PC.

Running Wine on Windows has been a fever dream of those responding to the siren call of "we do what we must, because we shouldn't" since at least 2004, when someone tried compiling Wine in Cygwin and trashed the registry of the host system.

The excuse is "what about ancient applications that don't run properly in recent Windows." But you know the real reason is "I suffered for my art, now it's your turn."

In late 2008, I got a bug in my brain and (I think it was me) started the WineOnWindows page on the Wine wiki. Summary: it was bloody impossible as things stood — going via Cygwin, MinGW or Windows Services for Unix. The current page isn't much more successful.

Windows 10 introduced Windows Subsystem for Linux — and the convenience of Ubuntu downloadable from the Microsoft Store. This makes this dumb idea pretty much Just Work out of the box, apart from having to set your DISPLAY environment variable by hand.

So far, it's mindbogglingly useless. It can only run 64-bit Windows apps, which doesn't even include all the apps that come with Windows 10 itself.

(The original inspiration was someone who couldn't run Encarta 97 on Windows 10. So, like any good geek solution, it doesn't actually solve the user's original problem at all.)

But I want to stress again: this now works trivially. I'm not some sort of mad genius to have done this thing — I only appear to be the first person to admit to it in public.

How to do this dumb thing

1. Your Windows 10 is 64-bit, right? That's the only version that has WSL.

2. Install WSL. Control Panel -> Programs -> Programs and Features -> Turn Windows features on or off — tick "Windows Subsystem for Linux". Restart Windows.

3. Open the Microsoft Store, install Ubuntu. (This is basically what WSL was created to run.) I installed "Ubuntu 18.04 LTS". Open Ubuntu, and you'll see a bash terminal.

4. Install the following from the bash command line:

sudo dpkg --add-architecture i386

sudo apt update; sudo apt upgrade

sudo apt install wine-stable

You can install a more current Wine if you want to faff around considerably. (Don't forget the two new libs that wine-devel >=4.5 needs that aren't in Ubuntu yet!) Let me know if it works.

5. Add to your .bashrc this line:

export DISPLAY=:0.0

You'll probably want to run that in the present bash window as well.

6. Install VcXsrv, which is a nicely packaged version of XOrg compiled for Windows — just grab the latest .exe and run it to install it. Start the X server from the Start button with "XLaunch". It'll take you through defaults — leave most of them as-is. I ticked "Disable access control" just in case. Save your configuration.

6a. If you want to test you have your X server set up properly, install sudo apt install x11-apps and start xeyes for a quick trip back to the '80s-'90s.

7. wine itself doesn't work, because 32-bit binaries don't work in WSL as yet — it gives /usr/bin/wine: 40: exec: /usr/lib/wine/wine: Exec format error on this 64-bit Windows 10. This is apparently fixed in WSL 2.

But in the meantime, let's run Wine notepad!

wine64 /usr/lib/x86_64-linux-gnu/wine/fakedlls/notepad.exe

TO DO: 32-bit support. This will have to wait for Microsoft to release WSL 2. I wonder if ancient Win16 programs will work then — they should do in Wine, even if they don't in Windows any more.

Handling 32-bit with qemu

Thanks to my anonymous commenter below, we have a route to 32-bit:

sudo apt install qemu-user-static

sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'

sudo service binfmt-support start

And now we can do:

fun@DESKTOP-7F6DU8P:~$ wine --version

wine-3.0 (Ubuntu 3.0-1ubuntu1)

Encarta 97 doesn't work, though:

fun@DESKTOP-7F6DU8P:/mnt/e$ wine SETUP.EXE

wine: Unhandled page fault on read access to 0xffffffff at address 0x11df:0x00002c11 (thread 0011), starting debugger...

0011:err:seh:start_debugger Couldn't start debugger ("winedbg --auto 15 108") (2)

Read the Wine Developers Guide on how to set up winedbg or another debugger

I'll leave that bit to someone who knows what they're doing. file says SETUP.EXE: MS-DOS executable, NE for MS Windows 3.x — so we need to get down to casually-clicked 16-bit programs working.

Encarta 97 installs and runs flawlessly in Wine 4.13 on Linux ... 4.13 on Windows 10 still fails:

fun@DESKTOP-7F6DU8P:~$ wine /mnt/e/SETUP.EXE

Xlib: extension "MIT-SHM" missing on display ":0.0".

Xlib: extension "MIT-SHM" missing on display ":0.0".

0009:err:process:__wine_kernel_init boot event wait timed out

001d:err:process:__wine_kernel_init boot event wait timed out

wine: Unhandled page fault on read access to 0xffffffff at address 0x11cf:0x00002c11 (thread 001e), starting debugger...001e:err:seh:start_debugger Couldn't start debugger ("winedbg --auto 28 152") (2)

Read the Wine Developers Guide on how to set up winedbg or another debugger

001d:err:ntdll:RtlpWaitForCriticalSection section 0x7e6273e0 "syslevel.c: Win16Mutex" wait timed out in thread 001d, blocked by 001e, retrying (60 sec)

Xlib: extension "MIT-SHM" missing on display ":0.0".

Could not load wine-gecko. HTML rendering will be disabled.

001e:err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x7b4a6abc

wine client error:1e: write: Bad file descriptor

Of course, it gave different error messages across multiple runs ...