Installing WINE

From: www.atomicmpc.com.au  read times: 185


Provided by yangyi at 2008-05-12 22:34:56


In our Linux gaming feature a couple of months ago we looked at Wine, the Windows compatibility layer that allows Linux users to run a number of Windows games, including recent hits like Team Fortress 2 and Call of Duty 4. It’s not the easiest thing to set up – not by a long shot, in fact – but that’s why we’re here. We’ll show you what Wine can do, how to get it working, and how to get the best out of it.

Removing the cork
The easiest way to get started with Wine is to install your distribution’s packages – ‘sudo apt-get install wine’ would do the job on Ubuntu, for instance. However, with the rapid pace of Wine’s development, these packages might be a few versions old. A good alternative is to use the official packages from the WineHQ download page, which are typically updated within days of each new Wine release. For most distributions, these are provided as repositories that you can add to your package manager, so you can easily keep up with new releases automatically.

Once it’s installed, you can run Windows .exe files by either double-clicking on them, or by running them at the command-line with the ‘wine’ command. For instance, if you have your Windows install handy, you could go to your ‘windows/system32’ folder and run:

wine sol.exe


Wine stores its data in the ‘.wine’ folder in your home directory, which is created the first time it’s run. Under this, there’s a ‘drive_c’ folder, which contains the contents of your virtual Windows system – any applications running under Wine see this as your C: drive, so it contains your ‘windows’ and ‘Program Files’ folders, among others.

Installing software under Wine is much the same as under Windows – just run the installer and step through. The files will be stored under your ‘.wine/drive_c’ folder, and on most distributions if the installer sets up shortcuts they’ll appear on the desktop or under your desktop menus. Alternatively, you can go in to your ‘.wine/drive_c’ folder and run the applications manually by double-clicking or using the ‘wine’ command.

For some games and applications, that’s all you need to do, but others will take a bit of tweaking. The best place to go for compatibility information, including the details on any tweaks required, is the Wine Application DB (appdb.winehq.org), but we’ll walk you through a few examples.

Steaming open The Orange Box
Valve’s games are the perfect starting point for jumping in to Wine: the Source engine runs well on Wine’s DirectX implementation, and using Steam gets around any disc-based copy protection issues. Follow these steps to get your Steam on:

1) Install the Gecko-based replacement for the MSHTML component, which Steam needs to render its internal web pages. It’s meant to install automatically when first requested, but this doesn’t always work with Steam, so it’s best to run Wine’s built-in ‘iexplore’ command instead:

wine iexplore http://winehq.org/


Close the browser window once the installation is complete.

2) Go to http://steampowered.com/ and download the Steam installer. Because it’s an MSI file, you need to launch it using Wine’s built-in MSI handler:

wine msiexec /i SteamInstall.msi


3) Step through the installer just as you would under Windows. When it’s complete, Steam should run automatically, but if not, you can launch it manually from Wine’s virtual C: drive:

cd “~/.wine/drive_c/Program Files/Steam”
wine Steam.exe


4) When Steam launches, log in to your account, and the main Steam window should appear.

Your existing purchases should be listed in the ‘My games’ tab as ‘Not Installed’, so you can re-download them for free. Alternatively, you can save yourself the bandwidth by copying the ‘steamapps’ folder from the Steam folder on your Windows drive to your new Wine Steam folder. Re-launch Steam after the copy, and your games should be ready to play.

Everything in The Orange Box should work without tweaking, though you may hit some performance snags or graphical glitches when using DirectX 9 features. The Source engine is nice and scalable though, so you can force games to run in DirectX 8 mode if required: just right-click on the game in the ‘My games’ tab, select Properties, click the ‘Set launch options...’ button, and enter ‘-dxlevel 81’.

Wine configuration
All good Linux tools are loaded with options, and like the blood in an anime character, Wine is filled to bursting point. The first port of call is, unsurprisingly, the Wine configuration tool, ‘winecfg’:

wine winecfg


Some of the key settings include:
Setting the version of Windows that Wine reports itself as, under the ‘Applications’ tab. You can set this on a global or per-application basis. This can be handy for getting specific applications running – 3DMark05, for instance, works with the ‘Windows 98’ setting, but not the 2000 or XP settings.

Audio acceleration options, in the ‘Audio’ tab. Many games only work when the ‘Hardware Acceleration’ option is set to ‘Emulation’, so try this if you have any in-game sound issues. It’s also best to pick one sound driver API to use (ALSA, generally), and disable the others.

click to view full size image


The ‘Enable a virtual desktop’ option, in the Graphics tab. This creates a single window on your desktop that all of Wine’s windows sit inside, which can help avoid window management issues with some applications. It’s also great for troubleshooting full-screen games, since the game is limited to the virtual desktop window, giving you full access to any Wine error messages.

DLL override options, in the ‘Libraries’ tab. Some of Wine’s built-in DLLs can be replaced with the original Windows versions for improved compatibility, but to use them, you need to add a manual override for the specific DLL involved. Civilization IV is a good example – you need to install a genuine ‘msxml3.dll’ file in to your ‘system32’ folder and add a DLL override to get it running.

You can find further options in the registry, which you can edit using Wine’s built-in version of ‘regedit’:

wine regedit


For instance, if you’re happy running Source engine games in DirectX 8 mode, you can improve performance by disabling Wine’s DirectX 9 shader support and using the older, but more heavily optimised, DirectX 8-only shader code. To do this, use ‘regedit’ to set the ‘HKEY_CURRENT_USER/Software/Wine/Direct3D/UseGLSL’ to ‘disabled’.

Home Wine-making
To get the best from Wine, building it from source is the way to go. It’s a little more complicated than installing packages since you need to install all of the libraries that Wine depends on before it’ll build, but it’s quite straightforward after that, and it’s a great way to give multi-core CPUs a workout.

1) Install the development packages required for building Wine, which includes the libraries and headers for X, OpenGL, ALSA, libjpeg, libgif, and libXML, among others. On Ubuntu, there’s a great shortcut for this using APT, since by default it tracks the build dependencies for each package. This means that you can install all of the build dependencies with one command:

sudo apt-get build-dep wine


2) Grab the latest Wine source code archive from the WineHQ download page, extract its contents, and change in to the newly-created directory:

tar jxf wine-0.9.55.tar.bz2
cd wine-0.9.55


3) Configure and build the source:

./configure --prefix=/usr/local/wine
make depend
make -j3


The ‘-j3’ option specifies the number of threads to use while building. This should be one more than your number of CPU cores to ensure that each core is always kept busy, so ‘-j3’ is perfect for a dual-core CPU, while ‘-j5’ would be best for a quad-core system.

4) Install the compiled copy of Wine:

sudo make install


Rather than overwriting any packaged versions of Wine you have installed, this version will be installed under ‘/usr/local/wine’. This folder won’t be searched for executables by default, so you’ll need to either specify the full path to the Wine executable when running it (‘/usr/local/wine/bin/wine’), or add this folder to your path, so that running ‘wine’ will find the new version:

export PATH=/usr/local/wine/bin:$PATH


You can add this to your ‘.bash_profile’ file to permanently modify your path.


click to view full size image


There are two main benefits to building from source, and the first is the ability to handle regressions. Wine is an incredibly complex product, and there are often times when a change in one part of the code can have unintended consequences elsewhere, or when a new implementation of something that may be an overall improvement is weaker in particular areas than the old version. In either case, you can get situations where a game that ran well with an earlier version of Wine runs poorly, or not at all, on the latest version, which is particularly annoying when the latest version includes fixes for other titles.

By building from source, you can have multiple versions of Wine installed simultaneously, simply by changing the prefix used in the ‘./configure’ command for each installation. For instance, you could install each version in to its own, version-numbered folder:

./configure --prefix=/usr/local/wine-0.9.55


To help manage this, you can use a symlink to point ‘/usr/local/wine’ to the most compatible version of Wine that you have installed:

cd /usr/local
sudo ln wine-0.9.55 wine


This way, you can run ‘wine’ as normal for the most part, while still having the flexibiltiy of using the full path to specify exactly which version to run when needed. Each time you install a new version of Wine, you can make the new version the default by updating the symlink, and if you run into problems, you can point it back to the previous version just as easily. The only catch is that you can’t actually run multiple versions of Wine simultaneously, so you’ll have to close down any applications running on one version of Wine before you can launch any with another.

Patching and Call of Duty 4
The other benefit to building from source is that you can patch the code to fix specific issues. Some games fall just short of running under Wine because a specific feature is missing, and in some cases, developers have put together quick fixes that address the issue just well enough to get a game going. Since they don’t truly solve the problem they’re not something that can be integrated into the Wine source code, but when building from source, you can add them in yourself.

Call of Duty 4 is a great example of a game that just needs a small patch to get running. It’s amazing that it works at all under Wine – unlike Team Fortress 2, which is based on a three-year-old engine that scales down nicely, COD4 runs on an all-new DirectX 9-only engine, so it pushes the graphics support in Wine to its limits. The frame rate isn’t fantastic, and you do have to disable a few effects, but the single-player campaign at least is more than playable.

The patch (which is really for 3DMark05, though it works with COD4 too) is available here – save its contents to a file called ‘wined3d-alphablend-hack.patch’. Install Wine from source as above, but after running the ‘make depend’ step, add the patch, and then continue with the remaining steps:

patch -p1 <~/wined3d-alphablend-hack.patch


If you had already installed from source, there’s no need to build the whole thing again – simply apply the patch as above, and re-run the steps after the “make depend” step. The build system is smart enough to only rebuild the source code files that the patch changed, so the rebuild will only take a few seconds.

To install Call of Duty 4 itself, you should be able to just run the installer from the DVD, though I didn’t have much luck with this. In the end, I had to install it under Windows and then copy the installed folder across to Wine’s virtual C: drive, and then install a no-CD patch to get around issues with the copy protection routines. You’ll also need to install ‘d3dx9_34.dll” – just search for it online and download it in to your same folder as COD4’s ‘iw3sp.exe’ executable.

If you installed the patch correctly, the game should start without a problem – otherwise, the game will complain about missing alpha blend features. Once you have it running, you need to disable the ‘Soften Smoke Edges’ and ‘Depth of Field’ options to prevent graphical corruption issues, but beyond that, you can adjust the other settings as required to find a good balance between shinyness and frame rate.

Message in a bottle
With so many settings to tweak, both in ‘winecfg’ and in the Wine registry, it can be a major hassle to reconfigure Wine when you switch from one game to another. The alternative is to install each game in to its own virtual Windows drive, with separate registries, so that you can tweak each of them independently. There’s a commercial version of Wine called CodeWeavers that does just this, calling the individual systems ‘bottles’, but you can do exactly the same thing with standard Wine:

1) Create a new folder to hold your Wine data and settings. As an example, we’ll make one for Call of Duty 4:

mkdir -p ~/wine/cod4


2) Run the ‘wineprefixcreate’ tool on this folder:

WINEPREFIX=~/wine/cod4 wineprefixcreate


If you check inside the folder, you’ll now see a ‘drive_c’ folder and registry files, just like in your ‘~/.wine’ folder. To run an application inside this system, set the WINEPREFIX environment variable when running ‘wine’, as we did with the ‘winprefixcreate’ command:

WINEPREFIX=~/wine/cod4 wine setup.exe


You’ll have to specify the WINEPREFIX each time you run an application outside of your normal ‘~/.wine’ folder. However, Wine is smart enough to automatically add the proper WINEPREFIX variable to any desktop or menu shortcuts created for installed applications, so if you launch everything through the desktop, it should Just Work (TM).

Original link: http://www.atomicmpc.com.au/arti...