Running Windows apps under Linux

LinuxWorld.com –

I have a confession to make. I run Windows on my laptop. That is, I run Linux, and then use Windows under VMware. This month I want to explore the various alternatives for running Windows applications under Linux. While I had long been aware of Wine and VMware, I had only recently heard about another approach: Win4Lin. With that in mind, I fired up Google (another Linux success story), ran a search on Windows emulators, and found one additional lead, Bochs. So this month, we will look at those four alternatives for running Windows applications under Linux.

I run Windows because many of my customers use it along with Linux, and I need to test the same Windows-based applications that they run. However, the main reason surfaced when I got my new laptop about a year ago. I felt adamantly that I would run Linux on it because I had lots of work to do on Ethereal and was writing a book on Samba. Unfortunately, I had several years of mail locked up in Eudora that I needed to access. I also needed to run Word, PowerPoint, and Excel on many occasions, and the dual-boot blues did not appeal to me any longer. So, I got VMware and loaded Windows under it, and I've been much more productive ever since.

While Linux makes great strides in the server space, many desktop applications still only run on Windows at the moment. Thus, many people out there can't run Linux exclusively but need a second system to provide access to the few Windows applications they use.

That fact highlights the need for Linux, though an excellent OS for many businesses, to coexist with Windows for the time being. Of course, we all expect Linux to prevail in the long run but, at the moment, it is often overlooked by people who are not aware that software exists to run Windows applications under Linux.

Wine is not an emulator

Wine is one of the oldest examples of such software. It is an open source package that implements the Windows 3.1 and Win32 APIs directly on Linux and X. It also provides a program loader and allows unmodified Windows programs to run under Linux (and other Intel x86-based versions of Unix). As such, it is not an emulator, and it should provide speed comparable to running your Windows programs natively on the same hardware.

To check out Wine, I downloaded the 091900 RPM from the Wine site and installed it. Besides RPMs for Red Hat 6.x and 5.x systems, the download area contains packages for Debian and the Wine source code.

Installation turned out to be the easy part, and even installing from sources looks relatively easy. However, to run Wine, you must ensure that your configuration file,

<font size=+0>/etc/conf/wine.conf</font>
, has correct information in it. You might choose to run Wine two different ways, with a Windows partition or without one. If you have a Windows partition, perhaps because you installed Linux in a dual-boot environment with Windows, you can run your Windows programs directly from that partition under Linux by using Wine. If you don't have a Windows partition, perhaps because you have simply copied your Windows application files into your Linux file system under the director
<font size=+0>$HOME/win</font>
, you can run Windows programs using Wine, but you will have to use the correct Wine configuration.

The Wine HOWTO contains detailed instructions on setting up Wine for both the above scenarios as well as installing Wine from sources.

While the Wine Website lists a large number of Windows applications that run under Wine, many more applications do not yet run under Wine and may never. However, Wine certainly is a low-cost way to run some of your Windows programs under Linux.

Interestingly, I found it impossible to run Wine on a kernel that had the Win4Lin patches applied, as Wine reported an unhandled exception and hung.

Wine is available from the Wine Website, and it requires an Intel or compatible processor. It runs on Linux, FreeBSD, and other versions of Unix that run on Intel platforms. Wine does not require a Windows license to run the Windows programs it uses.

Win4Lin

Win4Lin is an alternative to Wine that provides a much more complete Windows environment. Indeed, during installation it actually installs Windows for you. It was quite amusing to see the Windows installation screens running in a window under Linux.

The current version of Win4Lin is 1.0, but that version does not support SMP systems. Since I was initially testing Win4Lin on a SMP machine, I had to download the beta of Win4Lin 2.0. Win4Lin requires a Pentium-class processor with a minimum of 32 MB of memory and Linux 2.2.x.

Win4Lin only supports Windows 95 and Windows 98, and it does not support Microsoft Windows networking. However, it does have WinSock support, so many networking applications will work under Win4Lin.

The Win4Lin installation requires a custom kernel and a number of steps, and it is thus more difficult than any of the other alternatives mentioned here except Bochs. If you run a custom kernel already, you will have to apply the appropriate Win4Lin patch to your kernel by hand. The steps to install Win4Lin are:

Unpack your installation kit -- assuming you downloaded Win4Lin from the Web.

Install the custom kernel. If you have not made any modifications to your kernel, you can use the supplied

<font size=+0>install-kernel.sh</font>
script. The Win4Lin installation supplies patched kernels for a number of popular distributions. However, if you have applied other patches to your Linux kernel, you will have to apply the Win4Lin kernel patches and rebuild your kernel.

Install Win4Lin. You should do that by running

<font size=+0>install-win4lin.sh</font>
from your installation kit. If you are installing Win4Lin 2.0 or one of its betas, install the RPM. You must perform that step as root.

Install Windows on your system using the

<font size=+0>winsetup</font>
command. You must also perform that step as root.

Set up a personal copy of Windows 9x again, using the

<font size=+0>winsetup</font>
command. You must do that while logged in as the user who will use Win4Lin.

Once all that is done, you can run Windows by simply executing the

<font size=+0>win</font>
command. You will see a window that has Windows running in it. Of course, you will also have to install your Windows applications into the version of Windows running under Win4Lin.

During my testing, I installed Office 97 under Win4Lin and felt that the installation process was much faster than the same installation under VMware on the same system.

Win4Lin is commercial software that you can purchase from the Win4Lin homepage for $39.95, or $49.95 for the CD version.

VMware

VMware provides a very complete virtual machine environment that emulates an Intel x86-based computer, running under Linux as the host operating system (it also runs under Windows NT).

Since VMware emulates a PC, it comes complete with a BIOS, and you can change BIOS parameters in the same way as with a normal PC. The emulation is so complete that each virtual machine can have one or more virtual Ethernet devices for networking. Networking is discussed in more detail below.

You can download VMware from the company's Website either as a compressed TAR archive or as an RPM. If you have downloaded the RPM, installation is a two-step process.

First install the RPM, using your favorite rpm command:

<font size=+0>rpm -ivh VMware-2.0.2-621_i386.rpm</font>

Don't worry if your numbers are slightly different, as you may have downloaded a more up-to-date version.

Second, configure VMware to run on your system, using the

<font size=+0>vmware-config.pl</font>
command. I will discuss that step in more detail below because you will also need it if you install from a compressed TAR archive, and if you change your kernel.

If you install from the compressed TAR archive, the steps are:

Extract the contents of the TAR archive:

<font size=+0>tar zxvf VMware-2.0.2-621_i386.tar.gz</font>

Run the installation script:

<font size=+0>cd vmware-distrib
./vmware-install.pl</font>

After asking you a few questions about where to install VMware, the script then asks if you want to run the vmware-config.pl script. You should answer yes if this is your first install of VMware. The installation then proceeds, and you must read the end user license agreement. I will discuss the configuration script below.

When you install VMware from a compressed TAR archive, the installation script automatically runs the VMware configuration script,

<font size=+0>vmware-config.pl</font>
. If you install from an RPM or if you change your kernel, you will have to run
<font size=+0>vmware-config.pl</font>
manually. (In fact, if you go to run VMware and your kernel has changed, VMware tells you that you need to rerun
<font size=+0>vmware-config.pl</font>
.)

To run the script, simply type

<font size=+0>config-vmware.pl</font>
at the command line and follow the instructions provided by the script. You may need to have a C compiler installed on the system. If none of the prebuilt modules supplied with VMware are suitable for your kernel, the script will rebuild the modules. You will also be asked if you want your virtual machines to access the host filesystem. Samba makes that possible and, if you already have Samba installed or plan to install it separately, you should answer no.

Lastly, you will be asked if you want to use the network from your virtual machines. For most people, the answer will be yes. You can enable two types of networking. One is host-only networking, in which your virtual machines run on a virtual network and can only access your host system and each other. The other is bridged networking, in which your virtual machines are actually on the same ethernet as your host. You can use DHCP to allocate addresses for your virtual machines in either case.

Once you have installed and configured VMware, you can create a virtual machine and have it up and running within a few minutes after the install with VMware's configuration wizard. The wizard takes you through the steps of allocating space for the virtual machine's disk, which can be a partition or a large file in your Linux file system. The wizard also allows you to attach serial and parallel ports to the appropriate devices under Linux, so your virtual machine has the full complement of devices it needs.

However, once your virtual machine is up and running, you then have to install an operating system on it! That is just like installing an operating system on real hardware. As long as your virtual machine has access to a CD-ROM, simply place the install CD into your system's CD-ROM and power up your virtual machine (that is, click on the power button). Your virtual machine will run through the installation process and reboot at the end, just as Windows normally does.

In addition, VMware comes with a set of tools for each operating system that it supports. Those tools allow your virtual machine to gain high-speed access to the full display on your system instead of running in a window.

Because VMware provides a virtual machine, it is not restricted to running Windows. You can run quite a large number of operating systems under VMware, including MS-DOS, Windows 9x, Windows NT, Windows 2000, FreeBSD, and Linux. Thus, VMware is ideal for testing out new operating systems, providing a teaching environment, or grabbing screen shots of installation.

I also found the number of ways you can use VMware to be astounding. The Samba team uses it to test out changes to Samba by simply running Win NT in a virtual machine. I have used it to develop courses that deal with the installation of operating systems, including the booting phases, because I can very easily grab screen shots without the need for a digital camera. Also, if you run those virtual machines out of a virtual disk (a file in your file system) instead of a partition, it is very easy to copy your virtual machine to another system or keep backups.

The current version of VMware is 2.0.2, and it runs on all versions of Linux, including SMP systems, and on Windows NT and Windows 2000. It is priced at USD299 for commercial use and USD99 for hobbyist and student use. You can download it from the VMware Website. However, one of the things you will notice with VMware is that it requires more resources than Wine or Win4Lin. For example, a VMware virtual machine running on a 400 MHz Pentium II will feel like a real machine running at around 200 MHz to 266 MHz.

Bochs

Bochs, according to the Website, "is a highly portable x86 PC emulator written in C++ that runs on most popular platforms. It includes emulation of the Intel x86 CPU, common IO devices, and a custom BIOS. Currently, bochs can be compiled to emulate a 386, 486, or Pentium CPU. Bochs is capable of running most operating systems inside the emulation, including Linux, Windows 95, DOS, and recently Windows NT 4." It was developed by Kevin Lawton.

I have not downloaded or installed it, but mention it here as it may be an alternative for those running Linux on hardware other than Intel compatibles.

While Bochs is commercial software, the source is available on the Bochs Website, as are complete instructions for downloading and installing it. Installation of Bochs itself will be moderately complex for most people, as you must build the software from sources. Also, installation of an operating system under Bochs appears to be much more difficult than any of the other alternatives mentioned.

Conclusion

Well, there you are. I found four alternative ways of running Windows programs under Linux. Wine, Win4Lin, and VMware are all very well advanced, and the one you choose will depend on your needs.

If you only occasionally run Windows programs, Wine is the perfect choice for you. However, if you need to run a large range of Windows programs and need a more faithful Windows environment but can live with Windows 9x, then Win4Lin is likely to be the choice for you, especially if your budget is tight. On the downside, Win4Lin is much more complicated to install.

If your needs include running Windows NT or Windows 2000, or you need Windows applications that require Microsoft Windows Networking, then you will want to use VMware. If you are a student or hobbyist, then the $99 is not too much of a jump over Win4Lin. The commercial use price of $299 seems somewhat steep, but then VMware provides much extra functionality.

If you run Windows on a platform such as Alpha, Power PC, or Sparc, your only choice is Bochs.

A word of warning is appropriate, though. Windows is licensed software, and you must ensure that you have the appropriate licenses before running it in most of the ways mentioned above.

In future articles, we will explore the issues around backing up files in a mixed environment as well as how to set up file sharing between Linux and Windows, Network troubleshooting from Windows and Linux, and so on. I welcome your input on new topics to explore since your experience is likely to be as varied as mine.

Oh, and by the way, I am now determined to transfer all that Eudora mail to a Linux-based mail client. Perhaps I'll write a future article on mail clients that run under Windows and Linux, and allow you to access mail from either environment.

From CIO: 8 Free Online Courses to Grow Your Tech Skills
Join the discussion
Be the first to comment on this article. Our Commenting Policies