Sunday, February 15, 2009

Install xfig on MS Windows

This page shows how to install xfig 3.2.x on Microsoft Windows XP using cygwin.
  1. Directory assumptions:
    • cygwin is installed on c:\cygwin
    • GhostScript is installed on c:\gs.
    • Home directory c:\home
  1. Prepare environment variables.
    • Define the environment variable HOME to be the name of your home directory. You can follow these instructions to change environment variables.
    • Add these directories to your PATH environment variable. You can follow these instructions to change environment variables.
      .;c:\cygwin\bin;c:\cygwin\usr\bin;c:\cygwin\usr\local\bin;c:\cygwin\usr\X11R6\bin;c:\gs\gs8.xx\bin;c:\gs\gs8.xx\lib
    • Define the environment variable DISPLAY to be localhost:0
    • Download the .profile file and save it to your home directory.
    • Install the current version of cygwin.
      • Download the setup.exe from cygwin.
      • Run this file and select Install from Internet. After selecting a mirror site, it will let you select the packages you want to install. By default, cygwin installs a minimal set of packages, which is not enough in most cases. If you use cygwin not only for xfig, but also for other applications, and you have enough disk space, you can install all packages. If you only want to run xfig, you only need to install some packages. When selecting packages, be patient since cygwin may need several minutes to compute the dependent packages of the one you are selecting.
        (Note about packages: if you use MikTeX (a TeX distribution for Windows), do not select the ghostscript packages in the Graphics category and the teTeX packages in the Publishing category)
        After you have selected the packages that you want to install, you can go through the rest of the setup procedure following the instructions of the setup program. It is assumed that you have installed cygwin on d:\cygwin in the following steps. However, you can install cygwin anywhere as long as there is no space in the directory names.
      • For your convenience, mount some directories by running the following commands in the cygwin window. You must have the administrators privilege to do this if you are using NT/2000/XP. You can mount more if you have more drives.

        cd /
        mount -s -f c: /c
        mount -s -f d: /d
        Your home directory becomes /d/home instead of /cygdrive/d/home after this step.
    • Config X11 to run xfig
      • Cygwin/X is a free X server. You already installed X11 together with xfig when installing cygwin. You need to config X11 following these instructions:
        • Download xfree86.ico into your home directory. You should click the right mouse button and select "Save target as", so that these files are saved in text instead of HTML formats.
        • Create a shortcut (this page explains how to create a shortcut) named Cygwin/X on the desktop and input the following information:
          • Target: d:\cygwin\usr\X11R6\bin\startxwin.bat
          • Start in: d:\cygwin\usr\X11R6\bin\
          • Run: Minimized
        • If you have a two-button mouse, you need to set the target as below so that you can click both the left and right mouse button to emulate the middle button. You'll need the middle button a lot in xfig.

          d:\cygwin\usr\X11R6\bin\startxwin.bat -emulate3buttons
        • Click the "Change Icon" button and select the xfree86.ico file from your home directory
        • Now you are ready to run X11 from the X11 shortcut.
      • Run xfig.
        • Start the X server, a xterm window will show up.
        • Run xfig in the cygwin bash window (or xterm window if you use X11). Here is a screenshot when you run xfig with X11. Here is a screenshot when you run xfig with X-Win32.
      • Install GhostScript. Xfig uses GhostScript to export to eps files. You can use ghostscript to view ps file, convert ps to pdf, etc.
        • Download the latest version of GhostScript and GSView from here
        • Install GhostScript to d:\gs. You can install it to anywhere.
        • Install GSView. You can view ps and eps files from GSView. GSView can be installed into any directory
        • Since xfig looks for command "gs", put this file named gs into d:\gs\gs8.00\bin