Playing Windows games on Ubuntu with Wine

Wine [1], which is a recursive acronym for "Wine is not an emulator," is an infrastructure of applications and libraries that allows Linux users to execute programs developed for Windows. Versions of Wine also exist for BSD, Mac OS X, and Solaris.

As its name spells out, Wine is not an emulator as such, nor is it a virtualization program; instead, it is an open source implementation of Windows APIs, a series of "libraries" that allows you to execute Windows applications in Linux in much the way Microsoft executes old applications (e.g., MS-DOS applications) in compatibility mode.

Wine is available in Ubuntu's official repositories [2] and can be installed with your package manager of choice. The alternative is to use the official repositories of the project to ensure the latest version is installed with all the most recent security, performance enhancements, and other improvements.

Wine Installation

Wine can be installed several ways. It is an obligatory package in every self-respecting distro, and on Ubuntu you can install it with:

sudo apt-get install wine

The second approach is to install Wine through the project's official repositories, as mentioned above. For Ubuntu, that means adding the Wine repository to your system by executing:

sudo add-apt-repository ppa:ubuntu-wine/ppa

Note that for Ubuntu versions older than 9.10, you must add the repository manually.

To do this, go to Applications | Ubuntu Software Center , choose Edit | Software Sources , click the Other Software tab, and then press the button Add . In the APT Line text box enter

ppa:ubuntu-wine/ppa

and press Add Source . Now you can install the latest version of Wine directly through the Software Center.

The last way to install Wine is from the sources available online [3], but this method is tedious and complex because of the large number of dependencies, so we will not go through that process in this article.

Savoring Wine

Once Wine and all of its dependencies are installed, it is ready to use. Before this, we should make some remarks about the way the program works to maintain interoperability between Windows programs and your Linux system.

Wine's root directory is $HOME/.wine , which is the .wine folder in the home directory of the user. This directory is created the first time you run Wine. Wine includes a pair of programs that allows you to check whether everything has installed correctly. In the example, you can run Windows' Notepad application by opening a terminal window and typing:

wine notepad

For the time being, you can ignore all the error and warning messages that Wine shows and cancel all dialog windows (for a smoother and error-free Wine execution, see the "WineTricks" box).

WineTricks

Often, when you try to install a program, you will find that, to complete the install, you need certain add-ons for Windows, such as the Visual Basic 6 run time or the .NET framework.

A possible solution is to hunt for the package from the official website and install it by hand. Good luck with that. This option is not only frustrating (because it is not always possible to find said packages or libraries easily) but also tedious, especially when you need to add several packages.

A much better option is to use WineTricks [4], a program that allows you easily to find and install all the dependencies that your program could need.

To install it on Ubuntu, you must have Wine's PPA repository configured first. If you have added the repository when you installed Wine, you only have to install the package winetricks with the command:

sudo apt-get install winetricks

When you need to use it, you can execute it in a terminal with:

winetricks

When executed, a dialog comes up that lets you choose the libraries you want to install (Figure 2). Highlight the ones you need and press OK . The program will then download and install them automatically.

Figure 2: Winetricks makes solving the installation of Windows' program dependencies a piece of cake.

We recommend that you execute winetricks from a console to see what the program is doing because its GUI does not display the progress of what it's downloading.

Once you have your first Windows program running on Linux, take a look at the directory structure of Wine (Figure 1). Go to Notepad's Menu | File | Open , open up the locations box (Look in: ), and choose My Computer . You'll see two drives: C: and Z: .

Figure 1: Explore Wine's directory tree with Notepad.

Drive C: contains the "system" files that Wine requires to work. It contains the windows directory with libraries and executables, Program Files , and users . Drive Z: corresponds to the Linux root folder (/ ). In this way, Wine allows you to access your files on Linux outside its own directory tree.

On the Linux side, open a terminal and list the contents of .wine in your personal directory:

ls .wine

Here, you'll find the following folders:

  • dosdevices : Contains the mapping that Wine does of the different drives. In this case, it contains c: mapped to the drive_c directory, which is the system's drive; and z: , which is mapped to the Linux root directory (/ ).
  • drive_c : Contains the directories that Windows needs to be able to execute applications.

Inside this directory, you will find:

  • Program Files : Where Windows programs will be installed.
  • users : Where the user profiles are.
  • windows : Where the system files are.

When you install Windows programs through Wine, they will be installed in .wine/drive_c/Program Files . If you need any additional libraries to execute the program, you would need to copy them to .wine/drive_c/windows/system32 .

Home Fermentation

Wine's parameters are accessible by running the winecfg program (Figure 3), which lets you configure execution options – including the system being emulated (i.e., Windows 7, Windows XP, Windows 98, etc.), sound options, system libraries, storage drives, graphics options, and others – in a convenient and helpful GUI.

Figure 3: winecfg allows you to configure everything that has to do with your Wine installation.

Application Installation

All you need to do now is install a program – in this example, Macromedia Flash MX [5] (Figure 4). To begin, download the Windows executable to your personal directory and locate it with your file browser. In this case, the file is called flashmx_trial_en.exe . Right-click it and choose Open with Wine .

Figure 4: Flash MX working on Wine.

This step starts the installation wizard (Figure 5). If it did not work, you should open a terminal window and navigate to the directory in which the file is located. In this case, type

Figure 5: Application installation is identical to the Windows process.
cd $HOME/Downloads/

to move into your Downloads directory and then type

wine flashmx_es.exe

to see whether an error displays. Once the installation window comes up, you can proceed with the installation.

Drinking Games

Not only can you run serious applications in Wine, you can also use it to install and play games that were originally designed to be installed and played on Windows machines.

For the sake of simplicity, we will use WineTricks (see the "WineTricks" box) to install the components necessary to run more advanced games.

To begin, open WineTricks, choose Select the default wineprefix , and hit OK . In the next screen, select Install a Windows DLL or component and press OK . This should open a list of libraries and components, from which you should choose: d3dx9 , directx9 , gecko , and vcrun2005 . Install the component by hitting OK . Alternatively, you can run the following at the command line:

winetricks d3dx9 directx9 gecko vcrun2005

Without these components, you might not even be able to execute the installer.

The next step is to open your favorite text editor and create a new file called font-smoothing.reg with the content shown in Listing 1. This will make the fonts in your games look nice and smooth. From a terminal window, enter the folder where the created file is saved and run

regedit font-smoothing.reg

to copy the file to the Wine registry and activate it. Additionally, if you want to run a graphics-intensive game, you can follow the directions in the "Game Graphics" box.

Listing 1

Content of font-smoothing.reg

01 [HKEY_CURRENT_USER\Control Panel\Desktop]
02 "FontSmoothing"="2"
03 "FontSmoothingType"=dword:00000002
04 "FontSmoothingGamma"=dword:00000578
05 "FontSmoothingOrientation"=dword:00000001

Game Graphics

If you do not want a degraded game experience for games that are very graphic-intensive, you should disable all desktop effects (rotating cubes, 3D effects, wobbly windows, etc.). If you are using a laptop with the NVidia Optimus system, we recommend you install Bumblebee [9] to improve performance.

In the Wine configuration box (winecfg ), you should instruct Wine to simulate Windows 7. Once done, you can download and install a game on your machine.

Note that installers with different extensions will require different programs from the Wine menagerie. If the extension is *.msi , for example, you'd use msiexec . We are installing the demo of Diablo II [6] (Figure 6). Because this is a .exe file, you can install it directly:

Figure 6: RPG gaming in Diablo II courtesy of Wine.
wine DiabloIIDemo.exe

From this point on, the installation process is identical to a Windows installation. For more on how to install games and other applications, check out the Wine application database [7].

Oenology

Wine might not have the power to run Windows programs the way a virtual machine would because compatibility is not 100% for all applications. However, it is a very interesting option for running certain applications in such a way that they are integrated with your system, in that Wine lets you work directly with your directories and data without having to share folders with a virtual machine.

Another advantage is eliminating Windows completely from the equation. In fact, some commercial programs are distributed for Linux that are the exact same Windows programs with Wine integrated directly into the package. This is the case for LIMBO [8], for example. By using Wine, you can avoid paying a license fee for Microsoft's operating system, and the security of the application will be inherited from the Linux environment. If a program were to contain a vulnerability or malicious code, the damage it could cause would be limited because Wine is executed (or at least should be executed) with user privileges, never as root.