XView for Cygwin

blue bar

The XView toolkit was part of the Openwindows distribution from Sun. This page contains details of my port of Openwindows and the XView toolkit to work with Cygwin under Microsoft Windows.

Update: Current installations of Cygwin 1.7 already include the XView toolkit. There is no need for most of the additional steps listed on this page. You only need to follow the instructions in the Building XView applications section.

However, if you are running an older version of Cygwin (prior to ~ 2012) and the xview-dev package is not available through the usual setup, you can still follow the instructions on this page.

Why port XView?

Wouldn't it have been better to spend the time adapting my software to use a newer, supported, and 'better' graphical toolkit such as GTK, rather than port XView to Cygwin? Yes. But... sticking with XView also has advantages for compiling graphical software on multi-platform UNIX systems, in particular if it is to compile on old SunOS systems with only a K&R C compiler installed, no root access and limited disk space. The XView toolkit is also available for a range of other non-Sun UNIX distributions (see links below).

Porting notes

I'm a scientist, not a computer programmer. My motivation for porting XView to Cygwin was to use my existing software on Windows with as little amount of effort as possible. I don't understand the XView source code, how the make files work on a project of this scale or the philosophy behind graphical toolkits.

Except for the one case noted below, all changes to the source code are commented in #ifdef __CYGWIN__ blocks. I assumed that the Linux port would be the best starting point for Cygwin and then tried to fix those Linux ports that didn't work with Cygwin. This is likely to mean that I've introduced some bugs by failing to spot difference between Linux and Cygwin. Below, I've listed the major points of contention.

config
Basic modification of the files in the config directory to work with Cygwin. Build of the SunView conversion tool is suppressed but only because it's relevant Makefile needs fixing.
Build-CygwinXView.bash
This is a copy of the original Build-LinuxXView.bash with a work-around for the problem that the initial make clean, during the build, deletes object files with file extension *.obj under Cygwin. This conveniently deletes the XView.obj file in the config subdirectory.
ucontext_t
Rather than decide whether to return a struct sigcontext * or ucontext_t from notify_get_signal_context() in lib/libxview/notify/ndet_loop.c depending on flags related to the operating system, base the choice on whether SYSV_UCONTEXT is defined or not which is more consistent with the function definition in the related header file.
Regular expressions
The file chooser, in lib/libxview/file_chooser/file_list.c, uses regular expressions to match files. The code appears to access some internal members of the regular expression structures which do not appear in the usual regex man pages and do not appear to be defined by Cygwin. I've added a replacement using the normal regex commands, which compiles under Cygwin. However, I haven't tested it thoroughly and it's possible that the return values from the normal regex commands do not match those from the internal structure.
itimers
Xview uses both real and virtual itimer system calls. Cygwin only handles real itimer system calls so the functions which set and query the virtual itimer in lib/libxview/notify/ndet_loop.c return errors. As the code still appears to work, these error messages have been commented out although the virtual itimer system calls are still made. I don't understand this enough to appeciate what effect the lack of virtual itimers will have.
select, fcntl, read
Again, I don't quite follow what's going on in lib/libxview/notify/linux_select.c but using _select, _fcntl, and _read as defined by Cygwin and the portion of code defined for __GLIBC__ in linux_select.c seems to work.

Compiling

The Cygwin patch has been tested on version -21.1 of the XView source code from Debian. It is likely to work on future versions as well, as not much is changing in the xview source code. In addition to the default Cygwin install options you will need to select and download some additional items - I suggest those listed here.

Building XView applications

You will first need to define some environment variables which may be done in your start-up files, e.g. add the following line to the end of your .bash_profile file

export OPENWINHOME=/usr/openwin
To prevent warning messages, also do
cd /usr/lib
ln -s ../openwin/lib/text_extras_menu .text_extras_menu
ln -s ../openwin/lib/textswrc .textswrc
An additional library must be included during compilation. Also, the order in which the XView libraries are specified is important. I use
-L/usr/X11R6/lib -L${OPENWINHOME}/lib -lxview -lolgx -lrpc -lX11

Pre-complied XView and OpenWindows for Cygwin

A compiled version of XView and OpenWindows for Cygwin may be downloaded (5 Mb). It was compiled using the current Cygwin version as of 10th May 2007 on Windows XP. To install, copy the downloaded file to /usr in Cygwin and extract by typing

cd /usr
tar xjf cygwin_openwin_20070510dll.tar.bz2
Then edit the .bash_profile file in your home directory and add the following line to the bottom of the file
export OPENWINHOME=/usr/openwin
export PATH=${PATH}:${OPENWINHOME}/bin

Links

Multi-platform XView libraries and source code