# Getting Wine

If you decided that you can use and want to use Wine (e.g. after having read the introductory chapter), then as a first step you need to find a good compatible Wine version that you like and that works on your system, and after you found one, the next step is to transfer its files to your system somehow. This chapter is here to tell you what you need to take care of in order to successfully accomplish these two steps.

## How to download Wine?

There are three different methods of how the files belonging to Wine may be brought (downloaded) to your system:

- Getting a single Wine package file (specifically adapted to your particular system), which contains various binary files of Wine

- Getting a single compressed archive file (usually .tar.gz), which contains all source code files of a standard Wine release version

- Downloading from a CVS server, which contains the very latest development source code files of Wine

### Which Wine form should I pick?

Now that we told you about the different Wine distribution methods available, let's discuss the advantages and disadvantages of the various methods.

### Wine distribution methods

Wine package file

- Intended user level: Beginner to Advanced

  Using Wine package files is easy for three reasons: They install everything else that's needed for their operation, they usually preconfigure a lot, and you don't need to worry about compiling anything or so. You can get the official wine packages from the sourceforge.net Wine download page

Wine source code via archive file

- Intended user level: Advanced to Expert

  A Wine source code archive file can be used if you want to compile your own standard Wine release. By using differential patch files to newer Wine versions, you can easily upgrade your outdated Wine directory. However, as you need to manually download patch files and you're only able to download the most current standard Wine release, this is not necessarily the best method to use. The only advantage a Wine source archive has is that it is a standard Wine release with less development "quirks" than current CVS code. Except for that, CVS source code is much preferred and almost as easy.

Wine source code via CVS checkout

- Intended user level: Advanced to Expert/Developer

  The Wine CVS checkout offers the best way to take part in bleeding edge Wine capabilities and development, since you'll be able to download every single CVS commit even beyond the last official Wine release. As upgrading a Wine CVS checkout tree to the latest version is very easy, this is a recommended method of installing Wine. Plus, by carefully following the instructions in this Guide, you'll be able to gain the very best Wine environment compatibility (instead of falling victim to package maintainers who fail to follow some instructions in the Wine Packagers Guide).

To summarize, the "best" way to install Wine is to download Wine source code via CVS to get the newest code (which might be unstable!). Then you could easily compile and install the Wine files manually. The final configuration part (writing the configuration file and setting up the drive environment) could then be handled by WineSetupTk. All in all the best way to go, except for the about 500MB of disk space that you'll need.

With source code archive files, you have the advantage that you're running standard release versions, plus you can update to newer versions via patch files that we release. You won't have the newest code and the flexibility offered by CVS, though.

About binary package files: not sure. There's about a zillion reasons to not like them as much as you'd think: they may be outdated, they may not include "everything", they are not optimized for your particular environment (as opposed to a source compile, which would guess and set everything based on your system), they frequently fail to provide a completely configured Wine environment. On the plus side: they're pretty easy to install and they don't take as much space as a full-blown source code compile. But that's about it when it comes to their advantages. So I'd say they are OK if you want to have a quick way to have a test run of Wine, but for prolonged Wine use, configuring the environment on your own is probably better. Eventually this will change (we'll probably do some packaging efforts on our own at some time), but at the current explosive rate of Wine development, staying as close as possible to the actual Wine development that's going on is the way to go.

If you are running a distribution of Linux or some other system that uses packages to keep track of installed software, you should be in luck: A prepackaged version of Wine should already exist for your system. The following sections will tell you how to find the latest Wine packages and get them installed. You should be careful, though, about mixing system packages between different distributions, and even from different versions of the same distribution. Often a package will only work on the distribution which it has been compiled for. We'll cover Debian Linux, Red Hat, Mandrake, SUSE and Slackware Linux, FreeBSD, and other distributions.

If you're not lucky enough to have a package available for your operating system, or if you'd prefer a newer version of Wine than already exists as a package, you will need to download the Wine source code and compile it yourself on your own machine. Don't worry, it's not too hard to do this, especially with the many helpful tools that come with Wine. You don't need any programming experience to compile and install Wine, although it might be nice to have some minor UNIX administrative skills. Working from the source is covered in the Wine Developer's Guide. The main problem with externally maintained package files is that they lack a standard configuration method, and in fact they often fail to configure Wine's Windows environment properly (which is outlined in the Wine Packagers Guide).

## Getting a Wine package

### Debian Linux

In most cases on a Debian system (or any other distribution that uses packages that use the file name ending .deb, for that matter), you can download and install Wine with a single command, as root:

      # apt-get install wine

`apt-get` will connect to a Debian archive across the Internet (thus, you must be online), then download the Wine package and install it on your system. End of story. You might first need to properly update your package setup, though, by using an editor as root to add an entry to `/etc/apt/sources.list` to point to an active package server and then running `apt-get update`.

Once you're done with that step, you may skip the Wine installation chapter, since apt-get has not only downloaded, but also installed the Wine files already. Thus you can now go directly to the Configuration section.

However, if you don't want to or cannot use the automatic download method for .deb packages that `apt-get` provides, then please read on.

Of course, Debian's pre-packaged version of Wine may not be the most recent release. If you are running the stable version of Debian, you may be able to get a slightly newer version of Wine by grabbing the package from the so-called "unstable" Debian distribution, although this may be a little risky, depending on how far the unstable distribution has diverged from the stable one. You can find a list of Wine binary packages for the various Debian releases using the package search engine at www.debian.org.

If you downloaded a separate .deb package file (e.g. a newer Wine release as stated above) that's not part of your distribution and thus cannot be installed via `apt-get`, you must use `dpkg` instead. For instructions on how to do this, please proceed to the Installation section.

### Linux Red Hat, Mandrake, SUSE, and Slackware

Red Hat, Mandrake, SUSE and Slackware users can download a wine binary from the sourceforge.net Wine download page

### FreeBSD

In order to use Wine you need to build and install a new kernel with options USER_LDT, SYSVSHM, SYSVSEM, and SYSVMSG.

If you want to install Wine using the FreeBSD port system, run in a terminal:

      $ su -
      # cd /usr/ports/emulators/wine/
      # make
      # make install
      # make clean

This process will get wine source from the Internet, then download the Wine package and install it on your system.

If you want to install Wine from the FreeBSD CD-ROM, run in a terminal:

      $ su -
      # mount /cdrom
      # cd /cdrom/packages/All
      # pkg_add wine_.X.X.X.tgz

These FreeBSD install instructions completely install the Wine files on your system; you may then proceed to the Configuration section.

You can also download a FreeBSD package of wine from the sourceforge.net Wine download page

### Other systems

The first place you should look if your system isn't specifically mentioned above is the WineHQ Download Page. This page lists many assorted archives of binary (precompiled) Wine files.

You could also try to use Google to track down miscellaneous distribution packages.

## Getting Wine source code

If you are going to compile Wine (instead of installing binary Wine files), either to use the most recent code possible or to improve it, then the first thing to do is to obtain a copy of the source code. We'll cover how to retrieve and compile the source releases from the official archives, and also how to get the cutting edge up-to-the-minute fresh Wine source code from CVS (Concurrent Versions System).

Once you have downloaded Wine source code according to the instructions below, there are two ways to proceed: If you want to manually install and configure Wine, then go to the Compiling section. If instead you want automatic installation, then go straight to the Configuration section to make use of `wineinstall` to automatically install and configure Wine.

You may also need to know how to apply a source code patch to your version of Wine. Perhaps you've uncovered a bug in Wine, reported it to the Wine Bugzilla or the Wine mailing list, and received a patch from a developer to hopefully fix the bug. We will show you how to safely apply the patch and revert it if it doesn't work.

### Getting Wine Source Code from the official archives

The safest way to grab the source is from one of the official archives. An up to date listing is in the ANNOUNCE file in the Wine distribution (which you would have if you already downloaded it). Here is a list of servers carrying Wine:

- ftp://ftp.ibiblio.org/pub/Linux/ALPHA/wine/development/

- sourceforge.net download page

The official releases are tagged by date with the format "Wine-`YYYYMMDD`.tar.gz". Your best bet is to grab the latest one.

I'd recommend placing the Wine archive file that you chose into the directory where you intend to extract Wine. In this case, let's just assume that it is your home directory.

Once you have downloaded a Wine archive file, we need to extract the archive file. This is not very hard to do. First switch to the directory containing the file you just downloaded. Then extract the source in a terminal with (e.g.):

      $ tar xvzf wine-20030115.tar.gz

Just in case you happen to get a Wine archive that uses `.tar.bz2` extension instead of `.tar.gz`: Simply use `tar xvjf` in that case instead.

Since you now have a fully working Wine source tree by having followed the steps above, you're now well-prepared to go to the Wine installation and configuration steps that follow.

### Getting Wine Source Code from CVS

This part is intended to be quick and easy, showing the bare minimum of what is needed to download Wine source code via CVS. If you're interested in a very verbose explanation of CVS or advanced CVS topics (configuration settings, CVS mirror servers, other CVS modules on WineHQ, CVSWeb, ...), then please read the full CVS chapter in the Wine Developer's Guide.

#### CVS installation check

First you need to make sure that you have `cvs` installed. To check whether this is the case, please run in a terminal:

      $ cvs

If this was successful, then you should have gotten a nice CVS "Usage" help output. Otherwise (e.g. an error "cvs: command not found") you still need to install a CVS package for your particular operating system, similar to the instructions given in the chapters for getting and installing a Wine package on various systems.

#### Downloading the Wine CVS tree

Once CVS is installed, you can now do a login on our CVS server and checkout (download) the Wine source code. First, let's do the server login, to connect to the US server:

      $  export CVSROOT=:pserver:cvs@cvs.winehq.org:/home/wine
      $  cvs login

To connect to the EU server:

      $ export CVSROOT=:pserver:cvs@rhlx01.fht-esslingen.de:/home/wine
      $ cvs login

If `cvs` successfully connects to the CVS server, then you will get a "CVS password:" prompt. Simply enter "cvs" as the password (the password is case sensitive: no capital letters!).

After login, we are able to download the Wine source code tree. Please make sure that you are in the directory that you want to have the Wine source code in (the Wine source code will use the subdirectory `wine/` in this directory, since the subdirectory is named after the CVS module that we want to check out). We assume that your current directory might be your user's home directory. To download the Wine tree into the subdirectory `wine/`, run:

      $  cvs -z3 checkout wine

Downloading the CVS tree might take a while (some minutes to few hours), depending on your connection speed. Once the download is finished, you should keep a note of which directory the newly downloaded `wine/` directory is in, by running `pwd` (Print Working Directory):

      $ pwd

Later, you will be able to change to this directory by running:

      $ cd <some_dir>

where <some_dir> is the directory that `pwd` gave you. By running

      $ cd wine

you can now change to the directory of the Wine CVS tree you just downloaded. Since you now have a fully working Wine source tree by having followed the steps above, you're now well-prepared to go to the Wine installation and configuration steps that follow.

### Updating the Wine CVS tree

After a while, you might want to update your Wine CVS tree to the current version. Before updating the Wine tree, it might also be a good idea to run `make uninstall` as root in order to uninstall the installation of the previous Wine version.

To proceed with updating Wine, simply `cd` to the Wine CVS tree directory, then run, if you're using the US server:

      $ make distclean
      $ cvs update -PAd

The `make distclean` part is optional, but it's a good idea to remove old build and compile configuration files before updating to a newer Wine version. Once the CVS update is finished, you can proceed with installing Wine again as usual.

### Updating Wine with a Patch

If you got Wine source code (e.g. via a tar archive file), you have the option of applying patches to the source tree to update to a newer Wine release or to fix bugs and add experimental features. Perhaps you've found a bug, reported it to the Wine mailing list, and received a patch file to fix the bug. You can apply the patch with the `patch` command, which takes a streamed patch from `stdin`:

      $ cd wine
      $ patch -p0 <../patch_to_apply.diff

To remove the patch, use the `-R` option:

      $ patch -p0 -R <../patch_to_apply.diff

If you want to do a test run to see if the patch will apply successfully (e.g., if the patch was created from an older or newer version of the tree), you can use the `--dry-run` parameter to run the patch without writing to any files:

      $ patch -p0 --dry-run <../patch_to_apply.diff

`patch` is pretty smart about extracting patches from the middle of a file, so if you save an email with an inlined patch to a file on your hard drive, you can invoke patch on it without stripping out the email headers and other text. `patch` ignores everything that doesn't look like a patch.

The `-p0` option to `patch` tells it to keep the full file name from the patch file. For example, if the file name in the patch file was `wine/programs/clock/main.c`. Setting the `-p0` option would apply the patch to the file of the same name i.e. `wine/programs/clock/main.c` . Setting the `-p1` option would strip off the first part of the file name and apply the patch to `programs/clock/main.c`. The `-p1` option would be useful if you named your top level wine directory differently than the person who sent you the patch. For the `-p1` option `patch` should be run from the top level wine directory.