Official website for Linux User & Developer
FOLLOW US ON:
Aug
2

Use Wine to run Windows software on Linux

Posted by RussellBarnes

Sometimes using Windows applications is unavoidable, so in this tutorial we will make use of Wine to show you how to run Windows applications seamlessly within Linux…

On Ubuntu:
1. Open Ubuntu Software Center by opening Applications>Ubuntu Software Center.
2. Then click on Edit>Software Sources. Select the Other Software tab and click Add. Then enter the following apt line:

ppa:ubuntu-wine/ppa

3. Select ‘PPA for Ubuntu Wine Team’ from the Get Software Section on the left, then select Microsoft Windows Compatibility Layer (Development files) – wine1.3-dev. And click Install. This will install the latest Wine packages, including development libraries.
Tip: Uninstall the existing Wine packages for maximum compatibility. Also, for a clean install you can remove the Wine user directory by using the command ‘rm -r -v .wine’ from your home directory.

02 Installing Wine support packages
Now we need to install non open source (but free) support packages. These include packages such as Microsoft Core Fonts, Visual C++ runtime etc.
So let’s get on with it…

Install Cabextract :
This package is required to extract Microsoft .cab files.

$ sudo apt-get install cabextract

Download winetricks script:off
Now we need to download a nifty script called winetricks, which automatically downloads and installs the necessary support packages.

$ wget http://winetricks.org/winetricks

Now enter the following command to install the necessary support packages:

$ sh winetricks corefonts tahoma

Tip: You can also run winetricks without any command-line parameter so that you can select the packages you need to install from a nice GUI interface.

03 Installing Microsoft Office
In our example we’re going to install Microsoft Office 2007. Insert the Microsoft Office 2007 disc and right-click on setup.exe and select ‘Open With Windows Program Loader’. This should launch the Microsoft Office Installer. Install it in the usual way, as you would do on any Windows system.

Use Wine to run Windows software on Linux

04 Setting up libraries
Now that we have installed Microsoft Office 2007, we need to make sure that Wine is configured to use it properly. You see, Wine comes with its own implementation of various Windows libraries, but we can use the native Windows libraries directly to make sure that applications have maximum compatibility. Wine comes with its own configuration tool called winecfg. Among other things, it also allows us to switch between the built-in and the native version of the libraries.

Open the Wine configuration tool by entering the command ‘winecfg’ . Go to the Libraries tab and add riched20 and usp10 to ‘native, builtin’. This implies that Wine should first try to load the native Windows libraries and if they are not available it should try the built-in libraries.

05 Running Microsoft Office
Microsoft Office should now be available in the Ubuntu program menu. You can access it by going to Application> Programs>Microsoft Office.

It’s a pretty straightforward routine really. If you simply want to run the odd Windows program, assuming compatibility is good then you’re all set, but advanced users wanting to take things to the next level might want to read on…

Building Windows applications using Winelib
Wine is really very helpful if you want to become Microsoft-free. Even a third-party Windows application developer is at the mercy of MS these days. For instance, Windows Multimedia application developers rely on DirectX for the simplest of tasks. DirectX is Microsoft’s property, and nobody else has access to its source. Someday, Microsoft might create some distinctive features of DirectX which are not accessible to ISVs because they are undocumented. Windows Media Player would then be the best available multimedia player on the platform, because others were forced to rely on DirectX without having full control of it.
Welcome to the Linux arena, where nothing is impossible.

Let’s take the example of DirectX again. Wine has got is its own implementation of DirectX (built with the help of Transgaming Technologies). Wine implements common multimedia APIs, such as Direct3D, DirectInput, DirectSound, DirectShow and many others, by mapping them to powerful and open Linux equivalents like OpenGL, X11 and the ALSA/OSS API. Hence while porting your DirectX application to Linux you can use all these open technologies. Winelib can be used as a first step to get your application out of Windows and onto a Linux box. Then gradually you can take advantage of all that Linux has to offer.

Winelib is capable of running and compiling Windows applications on Linux without the need for Windows. Winelib is part of the Wine project. It is an open source implementation of the Win32 API built on top of Linux and the X Window System (often referred to as Xorg these days). Winelib shares 100 per cent of its code with Wine, and is capable of compiling both console and GUI applications. It is also capable of compiling library files like DLLs (dynamic-link libraries). Wine can handle your Windows source code in two ways…

Providing binary-level compatibility
Binary-level compatibility is achieved with Wine itself. In this process, application source code is compiled on the Windows platform and then the binary file is taken to the Linux system and is run through Wine. When the application is run with binary compatibility, it can use all existing .dll files. This process is pretty straightforward, but is not able to unleash the full power of the Wine subsystem. This is exactly the same way we are running Microsoft Office 2007 using Wine.

Providing source compatibility

In this method the source code file is taken to the Linux box, where it is compiled against the Winelib libraries using GCC. This way, the application will also be able to catch up with UNIX API calls in order to leverage the full power of UNIX. Winelib ships with a tool called winemaker, which creates a GNU-standard autoconf-based makefile out of a VC++ project. Winemaker is a Perl script that does all the dirty work involved in converting the source code, making it UNIX specific, clearing up cases issues and a lot more.

Theoretically speaking, converting a VC++ application to a Linux application involves the following steps:
1. Copy the VC++ project to a directory on a Linux box.
2. Change to the above directory and issue the following commands…

$winemaker -lower-uppercase$./configure -with-wine=/usr/wine/$make

And you are done. You can now install or execute the built binary.

Hello World
Let’s try Winelib on our favourite ‘Hello World’ Visual C++ application…

*--------hello.c ----------*/#include <windows.h>int main(int argc, char** argv) { MessageBox(NULL, “Hello Readers, Welcome to Winelib.”, “Hello”, MB_OK); return 0;}Compiling and executing$ winegcc hello.c -o hello$ ./hello.exe

Note:
You will need GCC 4.5 to build applications with Winelib. To install GCC 4.5, enter the following command:

$ sudo apt-get install gcc-4.5

Wine makes it relatively easy for your favourite Windows applications and games to run on Linux. If something is not working now, you may want to try the next version of Wine, as it is constantly being developed. If you are a Windows developer, Wine enables you to make your application natively available on the Linux platform. In future issues we will be looking into more Wine goodness.


Pages: 1 2
  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.

    10 Comments »

    • Buff Orpington said:

      I’ve been using Linux for over a decade and have never ever found a need to run Windoze software. WINE is there for those Wintards who just can’t leave their nanny behind. I suggest, that linuxuser just encourage them to grow up and move on (away from Windoze), and stop thinking like Wintards.

    • Avin said:

      Windows or Wine …..I think Only for Gamers

    • Yarrr said:

      I’ve been using wine for years under linux, and it keeps getting more and more compatible with well…games. That’s about all I use it for, but I do use them heavily. And for those here who have never had a need to run WIndows software, that’s great. Some of us do have that need, and it’s not a matter of “Growing Up”, it’s a matter of having software that we like and choosing to continue being able to use it. Wine allows me to do that, for which I am insanely grateful. Although yes, for me it is mostly for games, there are still some very boring productivity type programs that professionals will be able to use under linux thanks to wine. It’s a very necessary tool for a lot of us, and a very free, open source tool, so it’s development should be appreciated by all us penguin-loving geeks.

    • Troy said:

      Not so much software I prefer as much as software to convert proprietary file formats to text files which can be manipulated and uploaded via a serial connection a la screen or minicom. Sometimes, your job requires a tool which will not work with linux, but with wine I can use my OS of choice;-)

    • Server Management said:

      Been using wine for games mostly :)

    • Dilip singh said:

      Tips on wine helped me to recover my project. But it is not used i think. Though its for gamer some time we need it too. So its better to know and should be able to implement. That’s all

    • James said:

      Wine is also useful for software like Adobe Digital Editions which have a stranglehold over the epub market (including online libraries) but have no linux version.

    Trackbacks

    What's your opinion?

    Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

    Be nice. Keep it clean. Stay on topic. No spam.

    * Required fields