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).
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.
|
|
Here
are some tips on WINE to help you get a fair idea of its capabilities and
limitations:
|
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.
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.
Amit Singh <amits@netearth.iitd.ernet.in>
is studying computer science at IIT
Delhi
|
|
| FSF:
Free Software Foundation Inc, 675 Massachusetts Avenue, Cambridge, MA 02139,
US. E-mail: gnu@prep.ai.mit.edu.
Freeware: The word "free" in the title of the Free Software Foundation refers to "freedom," not "zero dollars." Anyone can charge any price for GPL-covered software that they want to. However, in practice, the freedom enforced by the GPL leads to low prices, because you can always get the software for less money from someone else, because everyone has the right to resell or give away GPL-covered software. GNU: A Unix-workalike development effort of the Free Software Foundation headed by Richard Stallman rms@gnu.ai.mit.edu. The GNU EMACS and the GNU C (gcc) compiler, two tools designed for this project, have become very popular in hackerdom and elsewhere. In the author's humble opinion, Stallman is one of the greatest forces ever to have influenced/shaped the Computer World. It stands for "GNU's Not Unix". GPL: The GNU General Public License. While the licenses for most software are designed to take away your freedom to share and change it, the GPL is intended to make sure that the software is free for all its users. Hacker: A person who enjoys exploring the details of programmable systems and how to stretch their capabilities, as opposed to most users, who prefer to learn only the minimum necessary. The term "hacker" is most often misused while referring to a malicious meddler who tries to discover sensitive information by poking around-one who breaks security on a system. The correct term for this sense is "cracker", a term the hackers have coined in defence against the journalistic misuse of "hacker". IDE: Integrated Development Environment. One example is the Borland Turbo C IDE which comprises a simple user interface for easy editing, compiling, debugging etc of C/C++ programs. Microsoft: A term often used to refer to Microsoft by the Unix hackers on the Internet. The `$' is supposed to be sarcastic, and the pun intended should be obvious. MS DOG: A term often used to refer to MS DOS by the Unix hackers on the Internet. It is supposed to reflect their attitude towards this OS. mwm: The Motif Window manager. Motif is almost a de-facto standard for GUI in the Industry. Windoze: A term sometimes used in the Unix community to refer to MS Windows (Mostly Windows 3.x, sometimes Win 95 and seldom NT). It is supposed to reflect the notorious `dozing' tendencies of MS Windows. Wizard: A person who knows how a complex piece of software or hardware works (in addition to hacking abilities, the Wizard also has an extrememly detailed knowledge along with the ability to fix things quickly, especially in an emergency. |
Asawari Ketkar