Grabber Softwares : Enhance Your Computing
WINE: The Windows Emulator For Linux

Run your Windows apps on Linux

In the legendary world of True Unix Wizards, there are certain rules to be followed. You have to be a GUI hater. You have to maintain that Microsoft (note the $) is the Computer God’s last curse upon earthlings—you can hate it, you can curse it, whatever, but you can NOT ignore it.

Moreover, you absolutely never call ‘it’ MS DOS... it necessarily has to be called MS DOG. Then there is Windoze, the ultimate living hell for your computer. In fact, for a change, I love to refer to these in a non-Unix-ish manner, in spite of all the thrashing they have had at the hands of countless people all the world over. It’s a pity that their user base is simply too large to do away with them.

While the commercial computer giants fight the traditional battle for supremacy, there is the incredible community of ‘hackers’ (this is a much misinterpreted word, see the glossary for the context in which I use this term here) that keeps surprising the computer world with its achievements. For instance, the impact of the now legendary GNU Project on the development and promotion of computer science is too colossal to be narrated here. These often unknown super-heroes (demi-gods to those who know them) are responsible for feats that may seem magical to most of the users. This article discusses one such wonderful example of freeware—WINE (the WINdows Emulator; however, WINE is not an emulator).Click Here For Higher Resolution

Consider running X on a Linux workstation, with mwm (Motif) managing the X Windows (take a look at the screenshot on this page). Do you see anything abnormal? Well, see the Borland Turbo C IDE running inside the X Windows titled ‘dos’. This IDE was fired after using DOSEmu (see PCQ May 1997, page 98) to boot Windows 95 in non-GUI mode. Apart from the familiar xclock and xterm clients, we also have the setup program for Microsoft Visual Basic 3.0 running here. Even if running MS Windows apps, MS DOS stuff, and X applications simultaneously on a single X Display doesn’t sound too useful to you, it sure is fun.

Users of Sun workstations may be familiar with running Win 3.x applets under Unix using WABI. With WINE and DOSEmu, it is possible to attain a reasonable degree of OS transparency on a Linux machine.

What the heck is WINE?

It is a cool program that can run MS Windows programs under X11. From the most ‘macro’ point of view, it comprises a program loader, a formidable piece of code that loads and executes a MS Windows binary. The Windows API calls that the program makes are translated to their Unix/X11 counterparts by an emulation library that sits in-between. There is NO machine level emulation of program instructions. It is also possible to compile MS Windows source code under Unix (running on an Intel x86 platform), using WINElib.

WINE Today

Here are some tips on WINE to help you get a fair idea of its capabilities and limitations:
  • WINE is still a developer’s-only release. Programs may ‘break’ or run in some unexpected manner.
  • MS Windows applets run under WINE with a varying degree of success. Some may not run at all. Others may work a treat.Most Win 3.x apps distributed with the OS, such as, MS Word, MS Project, MS Visual Basic... work with WINE, with the success depending upon a confusing mix of the WINE version, the available system memory, the OS ‘condition’, and of course the version of the Windows app.
  • Windows colors will usually vary from system to system. Don’t be too alarmed if some familiar applet looks off-color.
  • You will be running 16-bit MS Windows applications in a 32-bit operating system, courtesy Emulation Technomagic. One BIG advantage is, one MS Windows app crashing won’t affect other MS Windows or Unix apps running in their own X Windows.
  • Support for Windows networked applications which use WINSOCK.DLL is being worked upon, with the current version of WINE having some sort of a Winsock.
  • WINE isn’t meant to give Microsoft a run for their money. It is the cumulative effort of a number of powerful brains from different parts of the world. Evaluate WINE from a hacker’s perspective to appreciate it truly.

Getting Started
To get started with WINE, you’ll need:

  • A Linux system, with kernel 0.99.13 or above. If you run one of the 1.2.X kernels, you would be just fine. The 2.0.0 kernel was a major upgrade. It’s next version, kernel 2.0.30+, might be out as you read this. Needless to say, a fully functional X Windows system must be there as well. WINE will run on a NetBSD system or a FreeBSD system, but those Unix systems would be even less common than Linux in India
  • The XPM library, libXpm. Look for /usr/X11R6/lib/libXpm.<something>. If it’s not there, get it from ftp.x.org/or sunsite.unc.edu or ftp.funet.fi or tsx-11.mit.edu... the list is endless
  • WINE itself. Either get the source code from somebody who has it, or download it from sunsuite.unc.edu/pub/Linux/ALPHA/wine or from any other Linux site. Look for a newish version. The WINE distributions are named in the following manner:

WINE-970415.tar.gz where the cryptic 970415 denotes the release date for the distribution—April 4, 1997, in this case.

Now to get your WINE up and running, let’s assume that you’ve a file called WINE-<version-number>.tar.gz in /tmp. I’ll use the version number 970415 as an example, which is the current version of WINE available as I write this. The sequence of commands would be like this:

% cd /tmp
% gzip -dc WINE-970415.tar.gz | tar xvf -Wow ! ...Lots of files ...
% cd WINE-970415
% ./configure
Precompilation stuff ...Relax. It may take some time ... This must complete without any fatal errors ...
% make depend ; make

Unless you have an insanely fast machine (say, a Pentium Pro with tons of RAM), go and have a nap. Because this’s going to take really loooooooong.If everything went alright, you now have a "WINE" binary in the source directory. Note that it is a huge binary (more than 8 MB for 970415) because there’s lots of debugging info in the binary. If you do not intend to run a debugger on WINE, by all means you should run a ‘strip WINE’, which will get rid of a lot of symbols you won’t normally need in the binary. This reduces the binary size significantly (to about 1.45 MB for 970415).

CAUTION: You may need as much as 35 MB space just for compiling WINE. If you are tight on disk space, plan out the compilation carefully. I compiled it on a machine with only about 20 MB free disk space, managing the megabyte crunch by altering the Makefile to remove the object files after they had been linked to generate an intermediate module. Once WINE has compiled, however, you need just the space for the binary and the config files.

Running WINE

So, you are ready to start sailing now. I shall suggest a simple setup here—you may be as adventurous as you like. WINE expects a config file—/usr/local/etc/WINE.conf, but it is generally a good idea to use a .WINErc file in your home directory instead. We shall set up a simple ~/.WINErc to get WINE running. The format of this file is like a MS Windows .INI file.Click Here For Higher Resolution

For the purposes of experimenting with WINE, put all WINE stuff (except .WINErc) in the directory /tmp/WINE. This won’t clutter your disk, and you can remove all traces of WINE from your system should it happen to give you nightmares. I present here a brief but hopefully complete description of setting up WINE to run on your system, now that you have the WINE executable:

1. Create the following directories:
/tmp/WINE
/tmp/WINE/windows
/tmp/WINE/windows/system
/tmp/WINE/windows/temp

WINE has many of the MS Windows DLLs built-in. When an app doesn’t run with the error message that it cannot find a DLL, you will have to get hold of that DLL from your _real_ Win 3.x directory and place it in /tmp/WINE/windows or /tmp/WINE/windows/system wherever you find appropriate.

WINE prints warning messages indicating which of the built-in DLLs are being used. When some app crashes or doesn’t run at all, try placing the _real_ DLL in the right place (/tmp/WINE/<...>), so that WINE uses that instead of the built-in -there ones where there is half a chance that the app will run.

2. Copy the WINE binary to the /tmp/WINE directory. Also, append /tmp/WINE to the PATH variable:

% cp <wherever-WINE-binary-is> /tmp/WINE
% PATH=$PATH:/tmp/WINE
% export PATH

3. There would be a file called "WINE.sym" in the WINE source directory, which was generated when you compiled WINE. This file is a symbol table that the built-in debugger uses. Copy this over to /tmp/WINE:

% cp <wherever-WINE.sym-is> /tmp/WINE

4. Create a file .WINErc in your home directory. The contents of this file should be as in the box The .WINErc Source Code. These are pretty generic, and should work with little or no change. Either put this stuff in .WINErc, or look for a sample "WINE.ini" file in the source tree, which you copy as $HOME/.WINErc, and edit it accordingly:

;; Our simple wine configuration file.
;; The format is
;; [section name];; entry = value
;; entry = value
;; ...
;;
;; The A: Drive. For the Path value, use the directory
;; where you have mounted a DOS floppy. That is, if you
;; have done something like
;;
;; 'mount -t msdos -o rw /dev/fd0 /floppy'
;;
;; then Wine will see A: as your first floppy drive.
;; The serial number is an 8 character hex number used
;; to specify the drive serial number (use anything).
;;
[Drive A]
Path=/floppy
Type=floppy
Label=floppy
Serial=12345678
;;
;; By doing this, Wine will see /tmp/wine on your system
;; as the C: drive.
;;
[Drive C]
Path=/tmp/wine
Type=hd
Label=C Drive
Filesystem=unix
::
;; This makes wine access your cdrom drive. /cdrom is ;; the directory where you have mounted CD's in Linux.
;; That is, if you did something like
;;
;; 'mount -t iso9660 -o ro /dev/cdrom /cdrom' etc.
;;[Drive D]
Path=/cdrom
Type=cdrom
Label=CD ROM
::
;; Setting up the Wine directory. This will make Wine
;; believe that C:\windows (where C: is actually /tmp/wine
;; on the Linux system) is the MS-Windows directory to be
;; used. The rest follows ...
;;
[wine]
Windows=c:\windows
System=c:\windows\system
Temp=c:\windows\temp
Path=c:\;c:\windows;c:\windows\system;
;;
;; This file was generated when you compiled wine. Copy
;; this file from the wine source directory to /tmp/wine
;;
;; The symbol table file for the built-in debugger. Put
;; this in /tmp/wine as well.
;;
SymbolTableFile=./wine.sym
::
;; After all this is X11. Some things have to be kludged.
;;
[options]
AllocSystemColors=100
::
;; We don't have several MS-Windows fonts under Unix/X11.
;; So we cheat.
[fonts]
system=*-helvetica
mssansserif=*-helvetica
msserif=*-times
courier new=adobe-courier
times new roman=adobe-times
symbol=adobe-symbol
fixedsys=*-fixed
arial=*-helvetica
helv=*-helvetica
roman=*-times
default=*-*
::
;; Specify the devices to be used as com1 to com8
;;
[serialports]
Com1=/dev/cua0
Com2=/dev/cua1
Com3=/dev/modem,38400
Com4=/dev/modem
::
;; Specify the devices to be used as lpt1 - lpt8
;;
[parallelports]
Lpt1=/dev/lp0
::
;; Which of the messages from Wine are we interested in
;;
[spy]
Exclude=WM_SIZE;WM_TIMER;

Firing Win Apps In WINE

Now WINE should be able to run a MS Windows applet on your system. Try something small at first, like the calculator, calendar and the clock apps, etc. Once you are convinced that it works, graduate to larger apps such as notepad.exe, pbrush.exe etc. Then winfile.exe, winhelp.exe and so on.

Running an app is simple, but there can be some syntactical variations. The command will be:
WINE <path> sol.exeRun sol.exe
Where the <path> could be ./ (the current directory), /tmp/WINE/windows, or c:\windows\ (designated as C: in WINErc file) depending on where the file actually is.

Enough for this time to enjoy with? You will feel happier as you successfully run yet another program—the larger the merrier. It is possible to run many of the Microsoft heavy-weights (such as Word), but results will widely differ. And even if you cannot get WINE to work at all, there is every possibility that your attempts will lead you towards becoming a Wizard.