old-www/LDP/LG/issue80/taneja.html

249 lines
13 KiB
HTML

<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<title>Wine: Raising a toast to your Windows Apps on Linux LG #80</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<CENTER>
<A HREF="http://www.linuxgazette.com/">
<IMG ALT="LINUX GAZETTE" SRC="../gx/lglogo.png"
WIDTH="600" HEIGHT="124" border="0"></A>
<BR>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
<P>
</CENTER>
<!--endcut ============================================================-->
<H4 ALIGN="center">
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H1><font color="maroon">Wine: Raising a toast to your Windows Apps on Linux</font></H1>
<H4>By <a href="mailto:tech@gauravtaneja.com">Gaurav Taneja</a></H4>
</center>
<P> <HR> <P>
<!-- END header -->
<P STYLE="font-weight: medium"><FONT SIZE=3>When I first started
working on Linux some years back I did rely on a standby Windows OS
installed in another partition in case something would fail. But soon
I realized that this Open Source OS had everything to offer without
my spending a penny. However, there are still times when I feel the
need to fire up some application that's written exclusively for Windows. What
do you do in such a situation? The answer is Wine.</FONT></P>
<P><FONT SIZE=4><B>Wine has nothing to do with liquor !</B></FONT></P>
<P><SPAN STYLE="font-weight: medium"><FONT SIZE=3>There are products
like VMWare &amp; Win4Lin that will let you run another OS (usually
Windows) on a running</FONT></SPAN> Linux machine so that you can run
your Windows programs. You could also go in for a more traditional
approach of having another partition with Windows installed on
it.However, these alternatives are more of an overhead on your system
than a solution.</P>
<P>Wine stands apart from all these options, Wine, which stands for
&#147;WINE Is Not an Emulator&#148;, doesn't require you to buy a
Windows licensed copy. It it accomplishes this by rewriting the
complete Win32 APIs which differs from the Microsoft Code.</P>
<P><FONT SIZE=4><B>Let's Raise a Toast</B></FONT></P>
<P><SPAN STYLE="font-weight: medium"><FONT SIZE=3>If you would like
to try WINE, you can get the latest sources from the WINE
headquarters at <A HREF="http://www.winehq.com/">http://www.winehq.com</A>.
Building from source may not be necessary. The site has links to
daily builds in many different formats. Should you wish to obtain the
source and build for yourself, you&#146;ll find that it is pretty
straightforward.</FONT></SPAN></P>
<P STYLE="font-weight: medium"><FONT SIZE=3>The following steps can
be taken to accomplish your task:</FONT></P>
<PRE><I>gunzip Wine-20020411.tar.gz</I>
<I>tar -xvf Wine-20020411.tar</I>
<I>cd wine-20020411</I>
<I>./configure</I>
<I>make depend</I>
<I>make</I>
<I>make install</I>
</PRE>
If you are interested in the bleeding-edge version of Wine and as a matter of fact any major software you should
follow the path of CVS.The latest source in the CVS tree might prove to be more efficient in terms of raw performance.
The following procedure can be followed to grab the latest source:
<PRE>
<I>export CVSROOT=:pserver:cvs@cvs.winehq.com:/home/wine</I>
<I>cvnpres login</I>
</PRE>
When asked for password, provide 'cvs':
<pre>
<I>cvs -z 3 checkout wine</I></PRE><P>
You will see a steady stream of files coming into a directory called
&#147;<I>wine</I>&#148; relative to your current directory. After the
whole process is complete you can follow the same procedure of
compilation as above.</P>
<P><FONT SIZE=4><B>Wine Configuration</B></FONT></P>
<P>We will need a configuration file called &#147;config&#148; in the
&#147;<I>~/.wine/&#148; directory. You</I> can copy the a sample of
the same from the source directory:</P>
<PRE STYLE="margin-bottom: 0.2in"><I>cp documentation/samples/config ~/.wine/config</I></PRE><P>
The &#147;config&#148; file might appear daunting at a first glance
but you better stick to the defaults and change only the critical
parts that relate to your system.You will encounter a section
something like this:</P>
<P><I>[Drive A]<BR>&quot;Path&quot; = &quot;/mnt/fd0&quot;<BR>&quot;Type&quot;
= &quot;floppy&quot;<BR>&quot;Label&quot; = &quot;Floppy&quot;<BR>&quot;Serial&quot;
= &quot;87654321&quot;<BR>&quot;Device&quot; = &quot;/dev/fd0&quot;</I></P>
<P><I>[Drive C]<BR>&quot;Path&quot; = &quot;/c&quot;<BR>&quot;Type&quot;
= &quot;hd&quot;<BR>&quot;Label&quot; = &quot;MS-DOS&quot;<BR>&quot;Filesystem&quot;
= &quot;win95&quot;</I></P>
<P><I>[Drive D]<BR>&quot;Path&quot; = &quot;/cdrom&quot;<BR>&quot;Type&quot;
= &quot;cdrom&quot;<BR>&quot;Label&quot; = &quot;CD-Rom&quot;<BR>&quot;Filesystem&quot;
= &quot;win95&quot;<BR>; make sure that device is correct and has
proper permissions !<BR>&quot;Device&quot; = &quot;/dev/cdrom&quot;</I></P>
<P>Wine actually tries to emulate a DOS-like drive and folder
structure so the section which starts with &#147;<I>[Drive C]&#148;</I>
indicates the mapping of a hypothetical drive C: to your linux
directory which in our case is &#147;/c<I>&#148;</I>.</P>
<P>Next, some system folders like &#147;windows<I>&#148;</I> and
&#147;system<I>&#148;</I> are also mapped like this in the &#147;[wine]<I>&#148;</I>
section:</P>
<P><I>&quot;Windows&quot; = &quot;c:\\windows&quot;<BR>&quot;System&quot;
= &quot;c:\\windows\\system&quot;<BR>&quot;Temp&quot; = &quot;e:\\&quot;<BR>&quot;Path&quot;
= &quot;c:\\windows;c:\\windows\\system;e:\\;e:\\test;f:\\&quot;<BR>&quot;Profile&quot;
= &quot;c:\\windows\\Profiles\\Administrator&quot;<BR>&quot;GraphicsDriver&quot;
= &quot;x11drv&quot;<BR>; Wine doesn't pass directory symlinks to
Windows programs by default.<BR>; Enabling this may crash some
programs that do recursive lookups of a whole<BR>; subdir tree in
case of a symlink pointing back to itself.<BR>;&quot;ShowDirSymlinks&quot;
= &quot;1&quot;<BR>&quot;ShellLinker&quot; = &quot;wineshelllink&quot;</I></P>
<P><I><BR></I>We will have to create some the basic Windows directory
structure (&#147;windows<I>&#148;</I> , &#147;system<I>&#148;</I>
directories as mentioned in the &#147;<I>[wine]&#148;</I> section in
the &#147;config<I>&#148;</I> file:
</P>
<PRE><I>cd /c</I>
<I>mkdir -p windows/system</I>
<I>mkdir -p windows/Start\ Menu/Programs</I></PRE><P STYLE="font-weight: medium">
<FONT FACE="Times New Roman, serif"><FONT SIZE=3>The &#147;<I>[DllOverrides]&#148;</I>
section of the config file handles the DLLs that are supplied with
Wine to be used in place of their Windows counterpart and some native
Windows DLLs that you might want to use: </FONT></FONT>
</P>
<P STYLE="font-weight: medium"><FONT SIZE=3><I>; Be careful here,
wrong DllOverrides settings have the potential<BR>; to pretty much
kill your setup.<BR>[DllOverrides]<BR>&quot;commdlg&quot; = &quot;builtin,
native&quot;<BR>&quot;comdlg32&quot; = &quot;builtin, native&quot;<BR>&quot;ver&quot;
= &quot;builtin, native&quot;<BR>&quot;version&quot; = &quot;builtin,
native&quot;<BR>&quot;shell&quot; = &quot;builtin, native&quot;<BR>&quot;shell32&quot;
= &quot;builtin, native&quot;<BR>&quot;shfolder&quot; = &quot;builtin,
native&quot;<BR>&quot;shlwapi&quot; = &quot;builtin,
native&quot;<BR>&quot;shdocvw&quot; = &quot;builtin,
native&quot;<BR>&quot;lzexpand&quot; = &quot;builtin, native&quot;<BR>&quot;lz32&quot;
= &quot;builtin, native&quot;<BR>&quot;comctl32&quot; = &quot;builtin,
native&quot;<BR>&quot;commctrl&quot; = &quot;builtin,
native&quot;<BR>&quot;advapi32&quot; = &quot;builtin,
native&quot;<BR>&quot;crtdll&quot; = &quot;builtin, native&quot;<BR>&quot;mpr&quot;
= &quot;builtin, native&quot;........</I></FONT></P>
<P>Various Ports and devices also can be configured in the
<SPAN STYLE="font-weight: medium"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#147;</FONT></FONT></SPAN><I>[serialports]<SPAN STYLE="font-weight: medium"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#148;</FONT></FONT></SPAN></I>
section:</P>
<PRE><I>Com1=/dev/ttyS0</I>
<I>Com2=/dev/ttyS1</I>
<I>Com3=/dev/modem,38400</I>
<I>Com4=/dev/modem</I></PRE><P STYLE="margin-bottom: 0in; font-style: normal">
The general appearance of the windows can be changed in the
<SPAN STYLE="font-weight: medium"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#147;</FONT></FONT></SPAN><I>[Tweak.Layout]<SPAN STYLE="font-weight: medium"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#148;
</FONT></FONT></SPAN></I>section.</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><I>;; supported styles are
'Win31'(default), 'Win95', 'Win98'<BR>;; this has *nothing* to do
with the windows version Wine returns:<BR>;; use cmdline option
--winver if you want that.<BR>&quot;WineLook&quot; = &quot;Win98&quot;</I></P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<PRE STYLE="margin-bottom: 0.2in; font-style: normal"><FONT FACE="Times New Roman, serif"><FONT SIZE=4><B>Remember the Windows Registry ? </B></FONT></FONT></PRE><P>
Next, we need to install a default registry which will exactly match
the way registry exists on a Windows Box.But before you do this we
need to make minor changes to <SPAN STYLE="font-weight: medium"><SPAN STYLE="font-style: normal"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#147;</FONT></FONT></SPAN></SPAN><I>/etc/ld.so.conf<SPAN STYLE="font-weight: medium"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#148;
</FONT></FONT></SPAN></I>. We'll add a line <SPAN STYLE="font-weight: medium"><SPAN STYLE="font-style: normal"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#147;</FONT></FONT></SPAN></SPAN><I>/usr/local/lib/wine<SPAN STYLE="font-weight: medium"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#148;</FONT></FONT></SPAN></I>,
which relates to all the libraries used by the software to mimic a
Windows atmosphere.</P>
<P>Don't forget to run <SPAN STYLE="font-weight: medium"><SPAN STYLE="font-style: normal"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#147;</FONT></FONT></SPAN></SPAN><I>/sbin/ldconfig<SPAN STYLE="font-weight: medium"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#148;</FONT></FONT></SPAN></I>
after this step.</P>
<P>Next, we will use <B>regapi</B> to install a default registry.
From the Wine source directory issue the following command:
</P>
<PRE STYLE="margin-bottom: 0.2in"><I>programs/regapi/regapi setValue &lt; winedefault.reg</I></PRE><P>
<FONT SIZE=4><B>Let's Fire it up!!</B></FONT></P>
<P STYLE="font-weight: medium">Without waiting any further let's try
our hands on our Wine installation to run a simple Windows App.We
will try to run the standard Calculator which comes with Windows
(<SPAN STYLE="font-style: normal"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#147;</FONT></FONT></SPAN>calc.exe<I><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#148;</FONT></FONT></I>).</P>
<P STYLE="font-weight: medium">You can mount your windows partition
or copy the file <SPAN STYLE="font-style: normal"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#147;</FONT></FONT></SPAN><I>calc.exe<FONT SIZE=3><FONT FACE="Times New Roman, serif">&#148;</FONT></FONT></I>
with a floppy to your system in the folder <SPAN STYLE="font-style: normal"><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#147;</FONT></FONT></SPAN>/c/windows<I><FONT SIZE=3><FONT FACE="Times New Roman, serif">&#148;</FONT></FONT></I>
and use any one of the ways to start it up:</P>
<P STYLE="font-weight: medium"><I>cd /c/windows; wine calc.exe<BR>wine
/c/windows/calc.exe<BR>wine &quot;c:\windows\calc.exe&quot;</I></P>
<P STYLE="font-weight: medium">This is the way it appears on my Linux
box. Pretty amazing isn't it!
</P>
<P><BR><BR>
</P>
<P><IMG SRC="misc/taneja/calc.png" NAME="Graphic1" ALT="Calculator Screenshot" ALIGN=LEFT WIDTH=702 HEIGHT=426 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<P><BR><BR>
</P>
<P><B>Bye Bye for now!</B></P>
<P STYLE="font-weight: medium">Wine is pretty indispensable when you
have to run Windows executables on your Linux box but one thing to
note here is that not all of your Applications will work on Wine, you
will have to figure out ways and tweaks to make your favorite App.
work fine. But for many cases Wine proves to be of a great help.</P>
<!-- *** BEGIN bio *** -->
<SPACER TYPE="vertical" SIZE="30">
<P>
<H4><IMG ALIGN=BOTTOM ALT="" SRC="../gx/note.gif">Gaurav Taneja</H4>
<EM>I work as a Technical Consultant in New Delhi,India in Linux/Java/XML/C++.
I'm actively involved in open-source projects, with some hosted on
SourceForge. My favorite leisure activities include long drives, tennis,
watching movies and partying. I also run my own software consulting company
named <A HREF="http://www.broadstrike.com">BroadStrike Technologies</A>.</EM>
<!-- *** END bio *** -->
<!-- *** BEGIN copyright *** -->
<P> <hr> <!-- P -->
<H5 ALIGN=center>
Copyright &copy; 2002, Gaurav Taneja.<BR>
Copying license <A HREF="../copying.html">http://www.linuxgazette.com/copying.html</A><BR>
Published in Issue 80 of <i>Linux Gazette</i>, July 2002</H5>
<!-- *** END copyright *** -->
<!--startcut ==========================================================-->
<HR><P>
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</BODY></HTML>
<!--endcut ============================================================-->