Running Windows Applications in Linux

September 19, 2011 by . 3 comments

Ask some Windows users why they aren’t using Linux and chances are you will hear “because [program] doesn’t have a Linux version.” Although cross-platform software is popping up all over the place, there are still a number of applications that are restricted to a single platform – and for a lot of software, that platform is Microsoft Windows.

However, all is not lost. Although Linux has its own executable format and set of system libraries, a tool exists that will allows us to run a good portion of our Windows applications directly in Linux. This tool is of course, Wine. Wine initially began as a small project that was designed to run simple 16-bit Windows applications. As time went on, the target shifted to 32-bit applications and the long and hard process of rewriting Windows’ user-mode libraries began.

How Wine Works

Learning how to use Wine is easier if you understand exactly what Wine does. In order to explain things further, we need to take a look at how Windows applications work. This explanation might get a bit technical so feel free to skip this section if you have trouble understanding it.

A Windows application consists of binary machine code contained within a PE (Portable Executable) file. More than likely, the application makes use of one or more of Windows’ user-mode libraries for things like accessing files, creating graphical interfaces, and network communication. When Windows loads the application and begins running the code contained inside, it needs to know what user-mode libraries the application needs in order to run. This information is stored inside the executable file. Whenever the application needs to access a file or have the operating system perform some other task, it invokes the appropriate function in the user-mode library.

How does all of this relate to Wine? Well, Wine contains its own versions of most common Windows user-mode libraries and when it runs a Windows application, it simply directs the program to use its version of the libraries. Under those circumstances, the Windows application doesn’t really need to even be modified since it is performing the same instructions as it would on Windows – the only difference being that the user-mode libraries (and the appropriate code inside them) is designed to run on Linux.

How to Install Wine

The easiest way to install Wine on Linux is to check your system’s package manager to see if it already contains a pre-compiled binary that you can install. In Ubuntu, you can easily do this by visiting the Software Center and searching for ‘wine.’ If you prefer to install packages from the command line, use the following on a recent version of Ubuntu to install Wine:

sudo apt-get install wine1.3
Compiling Wine from scratch is slightly more difficult but provides you with access to the latest development versions. In order to go this route, you will need to determine what packages Wine requires for building. First off, you will need to make sure that you have a working C++ compiler (ideally g++ from the GNU Compiler Collection). The next step is to determine what packages provide the development files that Wine uses. Determining this can be tricky – a great place to find this information is the source package build dependencies page for a common distro like Ubuntu. This page, for example, lists all of the packages that the wine1.3 package needs to build on Ubuntu. Thankfully, if you are using Ubuntu, there is a very easy way to install all of them – run this command:
sudo apt-get build-dep wine1.3
Once you have all of the build dependencies installed, it’s simply a matter of getting the Wine source and compiling it. You can download one of the prepackaged source archives or you can checkout the latest development code from the Git repository using:
git clone git:// wine1.3
This will create a ‘wine1.3’ folder in the current directory with the Wine source code. Once you have the source code, you can run the following command to compile and install Wine:
./configure ; make ; sudo make install
That’s it! Wine is now installed and you can begin using it.

Running a Simple Application in Wine

The actual process of running a Windows application in Wine is very simple: just pass the name of the Windows executable file to the ‘wine’ command and Wine will take care of the rest. In fact, most of the time, Wine is smart enough to configure your desktop environment to launch Windows applications in Wine simply by double-clicking the executable file.

Let’s take a quick look at what this process involves by starting with something simple: Notepad. Wine ships with its own version of the classic Windows utility and running it couldn’t be easier:

wine notepad.exe
If everything is configured correctly, you will see something like this:

The Wine Application Database

Getting an application running in Wine isn’t always easy. A lot of applications require tweaking and playing around with settings and configuration files. Thankfully you can save yourself quite a bit of trouble by checking the Wine Application Database website. The site allows Wine users to submit feedback for a particular application and report whether they were able to successfully run the application or not. Each report can also contain specific instructions on how to best configure Wine and the application itself to give you the best shot at getting the application to run.

A very large percentage of applications will run unmodified and with no configuration changes. These are usually listed as ‘Platinum’ applications. There are other ratings, and you can see the full list and an explanation here.

What to Do If Your Program Won’t Run in Wine

If your Wine application refuses to run properly, there are a few settings you can change that might make the difference. Those settings can be accessed using Wine’s configuration utility. The utility can be started by running the following command:

The configuration utility provides a number of helpful options that control the way Wine operates or presents itself to an application. Probably one of the most frequently adjusted settings for me is the Windows version found in the Applications tab. Here you can select what version of Windows you would like Wine to “pretend” to be (you can select anything from Windows 3.1 to Windows 7). If an application is throwing errors or behaving incorrectly, sometimes simply changing the Windows version is enough to correct it.

If an application is choking on a particular .dll file that ships with Wine, you can instruct Wine to use the native .dll instead. Although less common, you can also do the opposite if an application is shipping its own version of a system library and you want Wine to use its own native version. Here are some of my .dll overrides:

As you can see, d3dxof.dll will use the native Windows version of the library (stored in the same directory as the application). quartz.dll on the other hand will use Wine’s version of the library instead of the native version included with the application.

I should also point out that there is a tool called winetricks that can help with downloading runtime and support libraries, such as the Microsoft Visual C++ runtime library (including multiple versions), the .Net framework runtime, etc.

If you still are running into problems, here are some resources for getting assistance:


Subscribe to comments with RSS.

  • TheLQ says:

    I have never gotten Wine to work correctly. Most of the programs I’ve had don’t work or work too slowly. Wine also pollutes the applications menu with so many different programs.

    I prefer virtual machines. Clean separation between Windows and Linux, and most programs work just fine without slowness.

  • Praveen says:

    Windows VM requires a license for Windows and also VM requires more RAM. There are upsides/downsides of using VM/Wind – depends on what we are looking at.

  • Steve Bennett says:

    You should do another blog post, about how to run Windows stuff on Mac. I have to use a mac for work, and find, ironically enough, that software is often available for Windows or Linux, but not Mac.

  • Comments have been closed for this post