I know there is a lot of tutorial how to install Wine 4 out there.
But there is little for specific distro like Elementary OS Juno and the explanation is not detail so error happening is always happen for newbie who has new in linux world.

This website is about Javascript but why we talk out of programming?

My reason to write this tutorial is:

  1. Wine is the simple way to make test our NodeJS application bundled for windows is running well or not. So if you passed in Wine, I can guarantee you application is also works 100% in real Windows.

  2. I has been moved from mac to use linux and Elementary OS is very similar with mac.

  3. Elementary OS is based from Ubuntu and the official repository from Ubuntu is still using Wine 3 version. Wine 3 is no too old to use, because for application which is using higher than Net Framework 4, is really worst, so you might not able to run many windows application today with Wine 3.

Before we going to the tutorial, You must know what is Wine was created for and how wine works behind.

What is Wine?

Wine is a free and open-source compatibility layer that aims to allow computer programs (application software and computer games) developed for Microsoft Windows to run on Unix-like operating systems.

How Wine works behind?

In above statement (I just copied from Wikipedia) means Wine works on layer to run windows application on top unix libraries. So Wine is not an EMULATOR or Cross Platform engine, so not all windows applications will be run seamlessly.

What Benefit using Wine?

Because Wine is not an Emulator or Cross Platform engine, the benefit is you will save a lot of memory resources. This is really fast and stable (Wine 4).

Tutorial

In this tutorial is for Elementary OS Juno, because EOS Juno is based on Ubuntu Bionic, so this tutorial might be also works for Ubuntu 18.04 (Bionic).

Install Wine 4

  • Setup PPA

    1
    2
    sudo dpkg --add-architecture i386
    wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add -
  • Add Repositories

    1
    2
    ###  Elementary OS Juno is based on Ubuntu 18.04 
    sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
  • Install

    1
    2
    sudo apt-get update
    sudo apt-get install --install-recommends winehq-stable
  • Troubleshoot
    If you face unmet dependencies error during installation,
    use the following commands to install winehq using aptitude.

    1
    2
    sudo apt-get install aptitude
    sudo aptitude install winehq-stable
  • Check Version
    To make sure Wine is installed properly, You can try to check the Wine version

    1
    wine --version

Winetricks

Winetricks is to make you easier manage the application or additonal library for windows. Also Winetricks will help you to install dependencies of Windows libraries like .dll, dotnet, etc. Because sometimes application installer doesn’t provide default dependecies.

Install Winetricks

  • Install

    1
    sudo apt install winetricks
  • Cleanup any application
    Before we going to set wine prefix, You are required to delete any installed windows applications first.

    1
    rm -r -f ~/.wine
  • Using 32bit only

    1
    WINEARCH=win32 WINEPREFIX=~/.wine wine wineboot
  • Using 32/64bit
    As default Wine will detect automatically your processor is 64bit or not. If your computer is 64bit, so default .wine directory is for 64bit application. To make Wine also works for 32bit, you have to create new .wine32 directory.

    1
    WINEARCH=win32 WINEPREFIX=~/.wine32 wine wineboot

Recomendations

I will recommend you to set Wineprefix to default 32bit only, because 64bit in Wine is still buggy and maybe you can not install dependecies properly from Winetricks. I’m not saying to not set prefix to 64bit, but there is more tricky and very hard for newbie to solving it.

Install Default Windows Fonts

Wine not install all default windows fonts, so many application looks bad because font is not installed.

1
sudo apt-get install msttcorefonts

Note: Sometimes wine will not see new fonts installed, so you need to restart the computer.

Most Common Problems

Icon Shortcut Not Working

Sometimes installer is finish to install windows application, but the icon shortcut is not working.
To solved this you have to edit the .desktop file.

Example cases:
I have installed Riot application from installer. So the wine path of it’s application is

1
/home/YOUR_USERNAME/.wine/drive_c/Program Files/Riot/Riot.exe
  • Edit the .desktop file
    First you can go to directory of wine programs shortcut in

    1
    cd /home/YOUR_USERNAME/.local/share/applications/wine/Programs/

    You will see that any application icon shortcut is placed in there.
    Now you just go inside the application directory in there.

    1
    cd Riot/

    Edit using nano editor

    1
    nano riot.desktop
  • Edit only the Exec= which is on line 3, become like this

    1
    2
    3
    4
    5
    6
    7
    8
    [Desktop Entry]
    Name=Riot
    Exec=sh -c "cd /home/YOUR_USERNAME/.wine/drive_c/Program\ Files/Riot/; wine Riot.exe"
    Type=Application
    StartupNotify=true
    Path=/home/YOUR_USERNAME/.wine/dosdevices/c:/Program Files/Riot
    Icon=31A0_Riot.0
    StartupWMClass=riot.exe

    Explanation:

    1
    Exec=sh -c "cd /home/YOUR_USERNAME/.wine/drive_c/Program\ Files/Riot/; wine Riot.exe"

    That command is same as in terminal to go directory Riot, then execute wine to run Riot.exe.
    Don’t forget to change YOUR_USERNAME with your username in Elementary OS.

    If you want to try, you can just download Riot application here.

Uninstall is not refresh the icon shortcut

To solved this you can just delete the .desktop file in

1
/home/YOUR_USERNAME/.local/share/applications/wine/Programs/

Conclusion

So far I use wine 4, for many windows application is around 80% is works properly. Almost game online which is required gameguard is fail to run.

I know there is a way to install Wine 4 by using snap or flatpack, but that is not good for newbie, because you will don’t know how wine is works behind and maybe you will be more dificult to use wine with winetricks.

And before you try to install some popular application, for example like Microsoft Office, Photoshop, etc. Better you check first in Wine DB to make sure it is running properly on your Wine (version 4) or not. So you can choose the version of application properly.