Monday, August 11, 2008

Run Windows Applications on linux

If the Windows applications you need to run just happen to be supported by Wine, you won't need to dual-boot or run an emulator. Just run the installers and launch the programs as if they were any other Linux app.
Novell, the company behind the SUSE distribution, recently ran a survey asking people which Windows applications they would most like ported to Linux. Adobe's Photoshop (number 1), Dreamweaver (3rd), and Flash (5th) all ranked very high (you can see the complete poll results here: http://www.novell.com/coolsolutions/feature/16917.html). Will Adobe be porting these much-requested apps to Linux soon, in response to the survey results? Probably not. But that doesn't mean you can't run them on Linux.
You can run all three of these applications, along with many more, thanks to Wine, an open source Windows compatibility layer. Wine is not an emulator (hence the name, in true GNU recursive style), but it does provide an alternative, 100-percent-non-Microsoft implementation of the DLLs that Windows programs use. (Wine can also use actual Windows DLLs as well.) The software has been in development for more than 12 years and just reached beta status in the fall of 2005. But Wine has been in widespread use for quite some time, and it's included in most distributions, including Ubuntu ).
Install Wine
The Wine software included with Ubuntu is frequently at least a step behind the current version, so to run the latest version you'll want to edit your /etc/apt/sources.list file and add Wine's own apt repository. You can do so manually, or with the Synaptic Package Manager.
To add the line yourself, open Terminal and enter this command:$ sudo nano /etc/apt/sources.list

After you furnish your password, the nano editor will open sources.list. Enter this line at the end of the file:deb http://wine.sourceforge.net/apt binary/
Save the file (press Ctrl-O), then open Terminal again and run:$ sudo apt-get update

This will update the package cache. Now you can install Wine with the command:$ sudo apt-get install wine

If you prefer to add the Wine repository and install Wine with Synaptic click SystemAdministrationSynaptic Package Manager and select SettingsRepositories. Then click Add, select Custom, and enter deb http://wine.sourceforge.net/apt binary/ in the APT Line field, as shown in .
Figure 9-1. Adding the Wine repository with Synaptic
Next, click Add Repository, and then click Reload to update the package cache. Now search for wine, highlight it, right-click the highlighted entry, and select Mark for Installation. Then click Apply, review the proposed changes, and click Apply again. Wine will proceed to download and install the latest version (0.9.10 as of this writing).
Wine is very much a work in progress, and each new version shows improvement, even if it sometimes temporarily breaks compatibility with Windows programs that formerly worked. The newer Wine is, the better it is, unlike its vintage namesake. Overall, each new version tends to be more stable and run more Windows software than its predecessor, so it's definitely worth running the latest version.
Configure Wine
The first thing you will want to do with Wine is configure it. You do so by running the Wine configuration utility, winecfg. In Terminal, enter:$ winecfg

Running this command will create the Wine configuration directory in /home/username/.wine. It will also bring up the tabbed Wine configuration interface shown in , which lets you adjust various parameters of your Wine installation, including the version of Windows that you want Wine to behave like. It's generally fine to accept the defaults, but you may find it helpful to add a new Windows drive (via the Drives tab) that explicitly maps to your CD-ROM drive. To do so, click the Add button to create a new Windows D drive, and then click Browse to select the path to your CD-ROM (such as /media/cdrom0/). Finally, click the Apply button to finish.
Figure 9-2. The Wine configuration interface
There's one more thing you should attend to before you begin to install Windows apps, and that is to install Microsoft TrueType fonts (so applications running in Wine can render text correctly) and cabextract, a useful tool for extracting the contents of Microsoft .cab archives. You can install both packages via apt by issuing this command in Terminal:$ sudo apt-get install msttcorefonts cabextract

You can also choose to install with Synaptic by searching for the msttcorefonts package, and then installing it. Synaptic will install the cabextract package along with msttcorefonts.
Install a Windows Application
OK, now that you have Wine, msttcorefonts, and cabextract installed, you can install your first Windows application. If you have it, you may as well choose Photoshop, since it is currently the most requested app for porting to Linux (actually, I think the GIMP is more than fine for most web graphics work, but I'll defer to popular opinion here).
Wine won't always run the current version of a Windows application; often, there will be some catching up to do. So, for example, the current version of Photoshop is not likely to work with the current version of Wine (although, at some point in their respective development cycles, it may). Usually, you will run Windows apps that are a generation or two behind. This is what I did with Photoshop. Since I tend to run that application more on OS X, my Windows version (Photoshop 6.0) is older. Photoshop 6 is no slouch in terms of functionality, though, and you can use these instructions to install a more recent version. Photoshop 7 is widely reported to work well, and it's possible you'll be able to get Photoshop CS working, too.
Pop the installation CD for your Windows app in your drive. Open Terminal and type the command wine, followed by the path to the installer. For example:$ wine "/media/cdrom0/Adobe Photoshop 6/Setup.exe"

That's it. If you're using an application that works with Wine, the installer will launch and install the application into the mock Windows filesystem in your .wine directory, as shown in .
Figure 9-3. Installing Photoshop on Ubuntu

Run Windows Applications
Now that you've installed a program, you can run itbut you have to find it first. For example, my Photoshop installation is located in the /home/username/.wine/drive_c/Program Files/Adobe/Photoshop 6.0/ directory. To launch Photoshop, I simply type the following command in Terminal:$ wine "c:\\Program Files\\Adobe\\Photoshop 6.0\\Photoshp.exe"

Photoshop will launch almost instantly And this old version runs fastprobably faster than it did/does on Windows. It also runs very well; I have yet to encounter any glitches.
Whenever you have questions as to whether a particular Windows application will work with Wine, you should consult the Wine Application Database at http://appdb.winehq.org/. Frank's Corner (http://www.frankscorner.org/) is another good resource for checking whether your application is likely to work.
Figure 9-4. Photoshop running on Ubuntu

Working with Wine
When Wine works really well, there's no better way to run a Windows application in a Linux environment. Many people dual-boot, of course, but that is really cumbersome when all you want to do is use a particular application. Other people run Windows itself using emulation software, but that is a less well-integrated solution, more resource-intensive, and generally not as fast. Wine enables Windows apps to run at native speed (at least) and to interact seamlessly with Ubuntu. Photoshop (along with other Windows apps) can open and save files anywhere on your computer, with no special effort required (there's no need for Samba-based file sharing between Ubuntu and your Windows environment, for example). In addition to the mock C drive installed by Wine, there is a Z drive that maps to your Linux filesystem.
Running Wine on your Ubuntu system is very straightforward. You've already seen how to install and then launch Windows applications. Some other basic Wine commands to keep in mind include:
wine control
Some programs (such as QuickTime) install associated control-panel applets; wine control will let you access them.
winefile
Running the winefile command will bring up a graphical interface, shown in that enables you to view your drive configuration and locate files. You can also run programs directly from this graphical environment; simply double-click on an .exe, just as in Windows.
Figure 9-5. Wine File, an Explorer-like graphical environment

uninstaller
The uninstaller program, shown in is similar to the Windows Add/Remove Programs control-panel applet. Simply highlight the program you want to remove and click Uninstall. It's that straightforward.
Figure 9-6. Uninstaller gives you an easy way to remove programs
You can access a complete set of Wine documentation at the Wine HQ site: http://www.winehq.org/site/docs/wineusr-guide/index.
Running Other Windows Components
In addition to various Windows applications, you may find it interesting to run various Windows components as wellnotably Internet Explorer, the infamous standards-shy browser that is nevertheless used by over 80 percent of all web surfers. There are a number of ways you can install IE.
The easiest way, by far, is to use one of the utilities that have sprung up around Wine to accomplish this very thing. The three major such utilities are WineTools (http://www.von-thadden.de/Joachim/WineTools/), Sidenet (http://sidenet.ddo.jp/winetips/config.html), and the awkwardly named IEs 4 Linux (so named because it will let you install IE 6, IE 5.5, and IE 5 all at once, if you so choose). Of the three, I recommend IEs 4 Linux (http://www.tatanka.com.br/ies4linux/). It is the only one that doesn't radically modify your Wine filesystem and that seems to work smoothly with the latest version of Wine.
To install IEs 4 Linux, first download it from here: http://www.tatanka.com.br/ ies4linux/en/instructions/. Then open the tar.gz file and run the ies4linux program that's inside. You'll be given a choice of which version(s) of IE to install; I chose IE 6 only. IEs 4 Linux will then proceed to download the version(s) you selected; IE 6 alone is an 80 MB download. The Microsoft browser(s) will be installed in a separate, .ies4linux directory in your home directory; your .wine directory is left untouched.
A nice, if rather bizarre touch: an Internet Explorer icon (customized with Wine glass and shown in is placed on your Ubuntu desktop. You can simply double-click it to launch the security-challenged browser, which defaults, for safety's sake, to an about:blank home page.
Figure 9-7. Internet Explorer on the Ubuntu desktop
Perhaps you don't want an IE icon on your desktopI certainly didn't. So I removed it and used Ubuntu's Applications Menu Editor to add Internet Explorer and some other Windows apps to the Ubuntu Applications menu. The result is shown in (you'll find the Wine glass in /usr/share/icons).
Figure 9-8. Adding Windows programs to the Applications menu
Note that Wine's commercial cousins, CodeWeavers' CrossOver Office(http://www.codeweavers.com/) and TransGaming's Cedega (http://www.transgaming.com/), can add the menu items for you

No comments: