X-Windows Applications on Interix

Microsoft Windows Services for UNIX 3.0

On This Page

Overview: X-Windows Applications on Interix Overview: X-Windows Applications on Interix
Overview of X-Windows System Overview of X-Windows System
Overview of X-Windows Application Development Overview of X-Windows Application Development
X-Windows Application Development X-Windows Application Development
Structure of a Typical X-Windows Program Structure of a Typical X-Windows Program
A Simple X-Windows Application A Simple X-Windows Application
X-Windows on Interix X-Windows on Interix
Porting X-Windows Applications to Interix: Prerequisites Porting X-Windows Applications to Interix: Prerequisites
Porting X-Windows Applications Porting X-Windows Applications
X-Windows Specific Porting Issues X-Windows Specific Porting Issues
LessTif Open-source Motif Library LessTif Open-source Motif Library
Sample Application – File Browser Sample Application – File Browser
LessTif Motif Library LessTif Motif Library

Overview: X-Windows Applications on Interix

Objectives

  • X Window environment

    • Overview of X Windows System

    • Overview of X Window development environment

  • Strategy for porting an X Window application

    • Pre-requisites and recommendation for porting

    • Dependency on the Operating system

  • X11 and Xm libraries for X window and Interix

    • Using 3rd party Xm libraries – scalability and issues
  • Porting a sample X Window program

    • Compiling 3rd party Xm library from LessTif

    • Guidelines for porting

    • Running X Window applications on MS-DOS

This section provides a brief overview of X-Windows and the guidelines for porting X-Windows application code to the Interix 3 development environment.

What you will learn

  • Fundamentals of X-Windows based GUI applications

  • Requirements for migrating an X-Windows application to run on Microsoft Windows

  • Guidelines and issues in migration

Prerequisites

It is essential to have a basic understanding of the Interix 3 development environment before going through this section.

Recommended Reading

The following reference is useful in understanding the X-Windows programming environment:

X Window System programming (Nabajyothi Barkakati, 1995. ISBN-81-203-0958-8.)

The following reference is useful in understanding Interix:

Services For Unix (Interix) Overview (Microsoft Consulting Services)

Overview of X-Windows System

  • What is X?

    • Combination of X protocol, X display Server, X Clients, and Xlib routines
  • Clients and Server

    • Clients - that may be running in remote computers

    • X Server - process executing on your workstation

  • X display server

    • The process executing in your workstation and managing the graphics output and the inputs from the keyboard and mouse.

    • Commonly known as "X Server"

    • E.g. Exceed from Hummingbird" and "ReflectionX form WRQ."

What is X?

X-Windows, typically referred to as X, is a combination of the X Protocol, X Display Server, X Clients, and Xlib routines. The X-Windows standard was developed with the aim of creating a platform-independent network-based graphical user environment.

X Clients are applications that use the workstation display. In a typical scenario, your workstation is connected to several other workstations through the local area network (LAN). With X running on your workstation, you can interact with several processes, each displaying in its own window on the screen.

Client and Server

Behind the scene is the X display server running on your workstation, listening to the network connections at a specific port, and acting on the commands sent by the X Clients (applications that use the workstation display).

The arrangement shown in the following figure illustrates the client-server model. The server provides a service that the clients request. Usually, the clients communicate with the server through a network, and the server and client process exchange data using a protocol understood by both the processes. You might have seen a client-server model in action. For example, a file server stores files and enables clients to access and manipulate the files. Similarly, as illustrated in the following figure, the X Display server offers graphics display services to clients that send X protocol requests to the server.

xwnntx01

In contrast to the file server, which usually are processes executing in remote machines, the X Display Server is a process executing on your workstation with clients that may be running on remote computers.

Please note that the client application and the X Server can run on the same machine.

The X Server

The functionality of the X-Windows System is in the X display server (or X server), the process executing on a workstation and managing the graphics output and input from the keyboard and mouse.

Creating a window is one of the basic X protocol requests that an X server handles. An X application often appears to have a single output window. In reality, however, most X applications use many windows to construct the user interface. The X server considers anything you do with the keyboard and mouse as events to be reported to the clients. When you are running X applications, everything on the screen appears in windows and each window is associated with a specific client. When you press and release a mouse button, the X server sends these input events to the client that created the window containing the mouse pointer.

Event Delivery

The X server also sends another kind of an event to clients. These events inform a client if anything happens to its window. For example, because windows overlay each other, when they are moved around, previously hidden parts of a window might become visible again. In this case, the X server will send an Expose Event to the client application, which must take care of drawing into the exposed part of the window. This is one aspect of the X server that usually surprises programmers who are new to the X environment. If an application code does not handle Expose events, nothing will be drawn on the window.

Overview of X-Windows Application Development

  • X Protocol

    • Completely defines the capabilities of the X Window System.Data is exchanged in an asynchronous manner over a two-way communication path.

    • Can be considered as the machine language of X

  • Xlib

    • Gives access to the X protocol through more than 300 utility routines. E.g, functions for Connecting to an X Display, Managing Events

    • Can be considered as the Assembly language of X

  • X Toolkits

    • Another set of routines to implement commonly created window objects such as pushbuttons, lists and menus. X Motif is one of the widely used toolkits

    • Can be considered as the High Level language of X

X Protocol

The X protocol defines exactly what can be achieved with the X-Windows System. In the X Protocol, data is exchanged in an asynchronous manner over a two-way communication path that enables transmission of a stream of 8-bit bytes. For example, a client can send a series of bytes to an X display server requesting it to draw a line. By drawing the analogy with the microprocessors, one might say that the X Protocol is the machine language of the X-Windows System.

Xlib

The X-Windows System comes with a library of C routines, commonly referred to as Xlib. Xlib gives access to the X protocol through more than 300 utility routines. If the X Protocol is the machine language, then Xlib is its Assembly Language.

The Xlib functions are used to accomplish the major tasks in an X application, such as:

  • Connecting to an X Display

  • Using resources in the Server (colors, fonts, etc.)

  • Drawing basic graphics elements (such as a line, circle, etc.)

  • Managing events

  • Handling errors

X Toolkits

It is very difficult to build a large application with Xlib. X Toolkits, another set of routines to implement commonly-created window objects, such as pushbuttons, lists, and menus, can be used to build a graphical user interface. The X-Windows System comes with the X Toolkit intrinsic that uses an object-oriented approach to implement basic building blocks called widgets. Other toolkits, such as the Motif toolkit from the Open Software Foundation, use a higher level of abstraction.

To summarize, the X-Windows System is a network transparent windowing system based on the client-server model. The X Server process, running on a workstation with a bitmapped graphics display, manages regions of the screen known as windows, where the output from an X client application is displayed.

The X clients, whether running locally or on a remote computer, send request to the server using a communication channel. The bytes exchanged between the client and the server conform to the X Protocol. X version 11 (X11), consists of the X Server, X Protocol, and Xlib. Xlib is a library of C routines that programmers use to access the server. X enables clients and servers to interoperate. For example, an X client on a system can display its output on any X server regardless of the display hardware or the operating system.

X-Windows Application Development

xwnntx02

The above figure shows the general structure of an X application. X applications primarily call routines from a toolkit. The toolkit may call routines from Xt intrinsics, which in turn call Xlib. An X application might also make some direct calls to some Xlib routines for generating text and graphics output in a window.

Dependence on Operating System

Basic X design does not depend on any OS, as long as common networking protocol is available for data transfer.

The basic design of X does not depend on any operating system. All X needs is a reliable data path between the clients and the X server. So far, X implementations have used TCP/IP, DECNET, and STREAMS networking protocols for transferring data between the server and clients. However, the operating system becomes a factor because of its close ties to the networking software that is being used by a client application to transmit the X protocol requests to the display server.

For example, in Berkerly UNIX (BSD UNIX) systems, X communicates using TCP/IP. AT&T's implementation of X uses the STREAMS mechanism that is native to the UNIX System V. Nevertheless, as long as there is a common networking protocol available for data transfer, the X server can display output from any client regardless of the operating system under which the client executes.

Structure of a Typical X-Windows Program

  • Initialization

    • Sets up window system for user interaction

    • Creates a top level window application

    • E.g toplevel = XtAppInitialize ( &app, "Hello", NULL, 0, &argc, argv, NULL, NULL, 0 ); //initialize a top level window

  • Event-loop

    • Repeatedly solicits events from window system

    • E.g XtAppMainLoop ( app ); //enter main event loop

  • Clean-up

    • Performs necessary clean-up

    • E.g XmStringFree ( xmstr ); //free compound string no longer used

A typical X-Windows program has three major sections:

  • Initialization

  • Event Loop

  • Clean-Up

Initialization

The initialization section sets up the window system for user interaction. In this system, it invokes the routines provided in X11, Xt, and Xm libraries to draw the various windows and graphics.

The call XtAppInitialize is provided by the X11 library, which creates a top_level window for the application. All the other windows are created as children of this top_level window.

Event Loop

After initialization, the program enters a loop in which it repeatedly solicits events from the window system and processes them.

The call XtAppMainLoop() is provided by the X11 library for entering the event loop.

Clean-Up:

Finally, before exiting, the program performs any necessary cleanups.

Usually the exit code is in a routine that is called when the user clicks on the exit button provided by the application (or on the close button on the window frame on the right top of the window).

Sample

The following sample code that displays the message "Hello World", basically uses all the sections defined above. This gives a solid example of how an X-Windows application using X Motif and X11 libraries is structured.

////////////////////////////////////////////////////////
// Hello World using C++ and Motif
////////////////////////////////////////////////////////
// Include files for X11
#include <X11/X.h>
// Include files for X Motif
#include <Xm/Xm.h>
#include <Xm/Label.h>
void main ( int argc, char **argv )
{
      Widget       label, toplevel;
      XtAppContext app;
      XmString     xmstr;
      Arg          args[10];
      int          n;
// Initialize the Intrinsics. This is a call provided by Xlib and is
// the first step in any X application
    
    
      toplevel = XtAppInitialize ( &app, "Hello", NULL, 0,
                                &argc, argv, NULL, NULL, 0 );
// Create a compound string to display the Hello message
     xmstr = XmStringCreateSimple ( "Hello World" );
// Create a label widget to display the string
 
 
    n = 0;
 
    XtSetArg ( args[n], XmNlabelString, xmstr ); n++;
 
    label = XtCreateManagedWidget ( "label", xmLabelWidgetClass,
                                   toplevel, args, n );
// Free the compound string when it is no longer needed.
     XmStringFree ( xmstr );
// Realize all widgets and enter the main event loop
    XtRealizeWidget ( toplevel );
    XtAppMainLoop ( app );
}

A Simple X-Windows Application

  • Specifying resources

    • Resource file – options for colors and fonts are specified

    • Advantage – avoids the hard coding of the resources

    • Can be located in the directory where the application is launched, if not then

      X will search for this file in the directory specified by the variable "XAPPLRESDIR".

      If no resource file exists for the application, then

      the file "app-defaults" from the directory /usr/X11R5/lib/X11/config will be used.

    • For example, a resource file looks something like this

      MyApp*MyAppMainWin.iconName:MYAPP //icons for the application

      MyApp*GraphView.iconName:ActivityView

Specifying resources

All X-Windows programs have associated resource files where options for colors, fonts, etc in the application can be specified. To take advantage of this capability, programs should be written such that hard coding of resources is avoided, so that resources specified in the configuration files are used.

The resource configuration file for an application will have the same name as the application specified in the call to XtAppInitialize. It can be located in the directory where the application is launched, or else X will search for this file in the directory specified by the variable XAPPLRESDIR. If no resource file exists for a given application, the file app-defaults from the directory /usr/X11R5/lib/X11/config will be used.

A typical configuration file will resemble the following:

MyApp*MyAppMainWin.iconName:MYAPP
MyApp*GraphView.iconName:ActivityView
MyApp*StackBar.iconName:OccupancyView
MyApp*GridOptionsDlg.dialogTitle:Grid Options
MyApp*ExtrapolationDlg.dialogTitle:Extrapolation Options
MyApp*FileSelectionDlg.dialogTitle:File Selection Dialog
MyApp*XmList*fontList: -adobe-helvetica-bold-r-normal--14-140-75-75-p-82-hp-roman8
MyApp*XmText*fontList: -adobe-helvetica-medium-r-normal--14-140-75-75-p-82-hp-roman8
MyApp*PushButtons*fontList: -adobe-helvetica-medium-r-normal--8-80-75-75-p-46-hp-roman8

Building an X-Windows Application

  • Compiling X Window Application

    • X application is written in C or C++ and compiled using any of the available C/C++ compilers in the system (e.g., gcc)

    • Needs to link with the X libraries: X11 (for Xlib), Xt (for Xt intrinsics) and Xm (for Motif toolkit)

      • X11 and Xt libraries are usually located in /usr/lib/X11R5 or X11R6 depending upon the version of X

      • The Xm library is usually located in /usr/lib/Motif1.x

    • The current version of X window specification is 11 and hence the name "X11". There are different revisions in version 11, currently running revisions are R5 and R6

    • "Makefile" is used to compile the X window application.

  • Using Imakefile and xmkmf

    • Typically a Makefile is created for compiling and building application as it involves references to many x11, Xt and Xm library paths, include paths etc.

    • 'xmkmf'- utility to generate the Makefiles for building the applications

    • Imakefile - input to xmkmf, provides the information required for building the application such as the file names, installation directory, library names, paths, include paths

    • System configuration files - contains system related information such as, compiler flags required, basic include library files and include paths

    • xmkmf uses system configuration with Imakefile to generate the Makefile for the application, for example:

      A Sample Imakefile is as shown below:

HEADERS =

SRCS = hello.c

OBJS = hello.o

MOTIFINCDIR = /LessTif-0.92.32/include/Motif-2.0

MOTIFLIBDIR = /LessTif-0.92.32/lib/Xm-2.0/.libs

LOCAL_LDFLAGS = -L$(MOTIFLIBDIR) –L$(YOURLIBDIR)

MOTIFLIB = -lXm

LOCAL_LIBRARIES = $(MOTIFLIB) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) -lm

DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)

clean::


     $(RM) $(OBJS) hello</pre>


  - **xmkmf** –a // This generates the Makefile

  - **make** hello //This compiles hello.c builds program hello
Building an X application

An X application is written in C or C++ and compiled using any of the available C/C++ compilers in the system (e.g., gcc).

An X application needs to be linked to the X libraries, X11 (for Xlib), Xt (for Xt intrinsics), or Xm (for Motif toolkit).

X11 and Xt libraries are usually located in /usr/lib/X11R5 or X11R6 depending upon the version of X that is supported by the system. (The current version of X-Windows specification is 11 and hence the name "X11". There are different revisions in version 11. The revisions currently in use are R5 and R6). The Xm library is usually located in /usr/lib/Motif1.x (depending upon the version of Motif that is installed on the system).

Using Imakefile and xmkmf

X-Windows system developers typically use a utility called 'xmkmf' to generate the Makefiles for building applications.Imakefile is the input to xmkmf, and provides the necessary information specifically required for building an application, such as the file names, installation directory, library names, paths, include paths, etc. System-related information, such as specific compiler flags required and basic include and library files and paths, are stored in various system configuration files. These system configuration files are used by xmkmf along with Imakefile to generate the Makefile for an application.

Below is a sample Imakefile required to build the program hello.c.

Note: Replace the LessTif installation path as per the installation on your system.

A sample Imakefile is shown below. It clearly shows the parameters, such as the source, object files, library includes, and other parameters, necessary to compile a simple "hello.c" application.

       DEFINES =
      
      
        HEADERS =
      
      
           SRCS = hello.c
      
      
           OBJS = hello.o
    
    
    MOTIFINCDIR = /LessTif-0.92.32/include/Motif-2.0
    
    
     YOURINCDIR =
 
 
 EXTRA_INCLUDES = -I$(MOTIFINCDIR) –I$(YOURINCDIR)
/* You can add any additional compiler flags here */
    USER_CFLAGS =
    MOTIFLIBDIR = /LessTif-0.92.32/lib/Xm-2.0/.libs
     YOURLIBDIR =
/* You can add any additional linker flags here */
  LOCAL_LDFLAGS = -L$(MOTIFLIBDIR) –L$(YOURLIBDIR)
       MOTIFLIB = -lXm
LOCAL_LIBRARIES = $(MOTIFLIB) $(XAWLIB) $(XMULIB) $(XTOOLLIB) \
                  $(XLIB) -lm
        DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) \
                  $(DEPXLIB)
ComplexProgramTarget(hello)
clean::
        $(RM) $(OBJS) hello

Now to build the program, perform the following steps:

  1. Type xmkmf –a and press Enter.

    This generates the Makefile.

  2. Type make hello and press Enter.

    This compiles hello.c and builds the program 'hello'.

X-Windows on Interix

  • INTERIX

    • An enhanced POSIX.1 subsystem that provides Unix like environment for developing and running application programs

    • provides X11 libraries for X Window applications, located in /usr/X11R5/lib directory

    • Currently Interix does not provide Motif libraries

  • 3rdparty Motif libraries

    • Motif library from LessTif.org is currently supported on Interix environment
  • 3rdparty X server

    • To run an X windows application on MS windows

    • WRQ's ReflectionX, Hummingbird's eXceed, and Tarantella's XVision are the popular X servers available

Interix 3 is an enhanced POSIX subsystem that provides a Unix-like environment for developing and running application programs.

To build an X-Windows application on Interix 3 or to port an X application from Unix, the Interix SDK provides the following compiler interfaces: cc , c89 , gcc , and g++ . To use cc or c89 , you must already have Microsoft Visual C/C++ setup and running because cc and c89 invoke the MSVC utilities CL.EXE and LINK.EXE by searching your path for the programs. If you are using gcc, then Visual C++ setup is not required.

  • Interix 3 provides X11 libraries for the X-Windows applications. These libraries are typically located in the /usr/X11R5/lib directory. The header files are located in the /usr/X11R5/include directory.

  • Currently Interix 3 does not provide Motif libraries. Therefore, you are required to install the Xm library on Interix 3 prior to porting any X-Windows applications that use the Motif library.

  • There are different third-party Motif libraries available for use. The only one that is currently supported on the Interix 3 environment is the Motif library from LessTif.org. This is an open source X motif library that is available under the GNU Library General Public License (LGPL). The sample applications shown in this document have been built and tested using the LessTif Motif library.

A ported X-Windows application is a Win32 executable. It uses the X server on a Windows NT/2000 machine just like any other Unix server communicates with an X server for displaying the windows.

Please refer to the document in Section 2: SFU/Interix overview for details about Interix 3 and the facilities that it provides.

Running an X-Windows application on Microsoft Windows

To run an X-Windows application on Windows, or any other operating system, one needs an X server. The X server is available on all Unix machines, typically supplied by the operating system vendor.

On Windows, you have a set of choices for X server. The prominent ones are:

  • Hummingbird's exceed/W

  • WRQ's ReflectionX

  • Tarantella's XVision

  • XFree86 from Cygnus

The above X servers can be considered as X-Windows emulators on Windows. They work in two modes:

Single Window mode

In this mode, all X applications run within one single window. The advantage of this mode is that users get access to a complete X desktop, which gives access to various X applications.

Multiple Window mode

Each X application runs within a separate window. In this mode, the X-Windows resource usage on the display server is lower compared to the Single window mode.

In the rest of the document, you will look at how to build an X application on the Windows platform to make it run as a native Win32 application within the Interix 3 environment.

Porting X-Windows Applications to Interix: Prerequisites

  • X server on the MS Windows

    • Acts as X window emulators on MS windows

    • Can use X Display Server such as eXceed or Xoftware

  • Interix installed on host machine

    • X11 and Xt libraries are provided by Interix
  • Motif libraries (from 3rdparty)

    • The Motif libraries can be obtained from LessTif

    • Compiling and installing the libraries is explained in later section

  • Understanding of writing and porting POSIX code on Interix

    • The application will very likely make use of various system calls such as opening and reading files

Prerequisites for Porting:

The basic requirements for porting an X-Windows application using Interix 3 are as follows:

  • The X Display Server, such as Exceed or ReflectionX, installed on the host machine running Interix.

  • The X11 libraries that are provided by the Interix subsystem.

Xm (X Motif) libraries on Interix.

The Motif libraries can be obtained from LessTif. In this document, a pre-compiled version of LessTif libraries version 0.92.32 is provided, on which the sample application was built. Instructions are also included for compiling the latest version of LessTif against Interix 3. Compiling the current version and installing it following the instructions provided will place the necessary libraries and header files where most X applications will expect them.

Note: Microsoft does not make any guarantees about the performance of LessTif libraries.

The latest version of LessTif source code can be obtained directly from https://www.LessTif.org. The details of compiling and installing the LessTif libraries are provided in a later section.

It is essential to understand the writing and porting POSIX code on Interix. The application will very likely make use of various system calls, such as opening files, and changes might be need to be made to the code using these calls.

Porting X-Windows Applications

  • Setup build environment on Interix

    • Interix provides compilers and Make utilities

    • If there are any special tools or utilities used on Unix environment, the equivalents should be installed on Interix.

    • Make sure that the path for motif include and library are defined in Imakefile as shown below:

MOTIFINCDIR = /LessTif-0.92.32/include/Motif-2.0 MOTIFLIBDIR = /LessTif-0.92.32/lib/Xm-2.0/.libs

  - Compile the source code using the 'Makefile', generated as explained before.
  • General porting issues

    • Differences in environment

    • Differences in Header files and APIs

    • Porting shell scripts

When porting any application to Interix, the first step is to ensure that the build environment is fully setup on Interix. Interix 3 provides compilers and Make utilities. However, if there are any special tools or utilities used on Unix environment, the equivalents should be installed on Interix 3 or they should also be ported from Unix.

Quite often, code for X-Windows applications are generated using specific tools. If your code is created using a code generator and the code generator is not available on Interix, you must take the code that was generated using the code generator to Interix 3 and port it.

The next step is to compile the source code and resolve issues as they appear. Typical issues are related to path differences, potentially non-existent device files, environment differences, etc.

There could be differences in the header files and in specific APIs, or there may be missing header files and APIs. The differences can be resolved by writing Interix 3 implementations for the APIs and header files. Please refer to the POSIX application porting guidelines at the end of this document for more details.

If your applications include scripts, such as Perl scripts, these will have to be modified to account for the platform differences.

Now you will look at the changes that are required to be made specifically to X-Windows applications to port them to Interix.

X-Windows Specific Porting Issues

  • Include and library paths for X11 and Motif

    • For Motif, this has to be done in the Imakefile

    • For X11, Interix.cf in /usr/X11R5/lib/X11/config directory

  • Setting DISPLAY environment variable

    • Running directly from command prompt, value for DISPLAY should be set in the Windows environment

    • Running the application from an Interix shell, DISPLAY would be set in the profile of the shell

  • Re-directing standard output

    • X window applications are started on UNIX terminal all the standard output calls direct the output to this terminal

    • In Windows, when an X window application is launched, a command window is started and all the standard output is re-directed to it

  • Environment variables

    • X applications use the environment variables such as XFILESEARCHPATH, XAPPLRESDIR

    • The values for these variables in INTERIX are the same as those in Unix

  • Font usage

    • Provided by the X server running on INTERIX

    • Use the fonts provided by X server to avoid conflicts

  • Issues specific to 3rdparty Motif libraries

    • Differences in the behavior of Motif Widgets provided by the Motif library

    • Refer to relevant documentation for the library

Include and library path settings

You might need to modify the paths for including the X11 and X Motif include files and libraries. For Motif, this has to be done in the Imakefile (please refer to the sample Imakefile specified earlier). For X11, this setting should be already available in the file Interix.cf in /usr/X11R5/lib/X11/config directory.

X11 include path:	 /usr/X11R5/include 
Xm include path:	 	 /dev/fs/C/LessTif/include/Motif-2.0 
X11 Library path:	 /usr/X11R5/lib 
Xm Library path:	 	 /dev/fs/C/LessTif/lib/Xm-2.0

If you compile and install the latest version of LessTif, using the instructions later in this document, LessTif and the Motif libraries and include files will be placed in the more normal locations:

X11 include path:	 /usr/X11R5/include 
Xm include path:	 	 /usr/X11R5/include/Motif-2.0 
X11 Library path:	 /usr/X11R5/lib 
Xm Library path: 	 /usr/X11R5/lib/Xm-2.0

Setting the DISPLAY variable

Any X application uses the variable DISPLAY to determine where the X server is located. Therefore, you must set the DISPLAY explicitly even when the application is running on Interix 3 (even though you might expect the application to use the X server on the local machine).

If you run the application from an Interix shell, DISPLAY should be set in the profile of the shell. If you try to run the application directly, say by double-clicking the application icon in explorer, then the value for DISPLAY should be set in the Windows environment or passed directly to the application via the command line in the shortcut.

Re-directing Standard output

Typically X-Windows applications are started on UNIX from a terminal. All the standard output calls direct the output to this UNIX terminal. If the application is not started from a terminal, the output goes to /dev/null.

In Windows, when an X-Windows application is launched by double-clicking the application icon in explorer, a command window is started and all the standard output is re-directed to it.

X-Windows Specific Porting Issues

X Environment variables

X applications use the environment variables, such as XFILESEARCHPATH and XAPPLRESDIR. The values for these variables in Interix 3 are the same as those in UNIX.

For example, if XAPPLRESDIR is /usr/X11R5/lib/X11/app-defaults in UNIX, it will be in the same location in Interix 3 -- /usr/X11R5/lib/X11/app-defaults. Previous versions of Interix did not support a single root filesystem and used different locations.

Font Usage

Some X applications might use fonts specifically provided by an X server on the existing system (on UNIX), which need not be provided by the X server running on Interix. If this is the case, then the program might not display the fonts properly or even crash during runtime giving error messages.

The solution to this problem is to replace such fonts with the fonts available in the X server used on Interix.

Using Icons

By default, X-Windows applications come up with a large X as the icon. To change the icon, one can use the resource 'iconPixmap' and set it in the resource file for the application to refer to the file that has the pixmap.

*iconPixmap: my_icon.xpm

This will make the icon "my_icon.xpm" to be used by all the windows of the application. It is also possible to specify different icons for different windows in the application. For example:

*editDialog*iconPixmap: edit_icon.xpm
*searchDialog*iconPixmap: search_icon.xpm

Issues specific to Third-party Motif Libraries

There might be differences in the behavior of Motif Widgets provided by the Motif library. These should be available in the relevant documentation for the library and will have to be considered for porting the application.

LessTif Open-source Motif Library

  • Installation of LessTif on Interix

    • Provides Motif Widget implementation for Motif 2.0

    • Claims support for INTERIX 2.2, however does not provide pre-compiled libraries for any version of Interix

    • This document contains zip file for LessTif Motif libraries version 0.92.32

    • To install - unziping the attached file will create the directory C:\LessTif-0.92.32\ and you should see 'include' and 'lib' directories under that, ready to use

  • Identifying issues with LessTif

    • You may want to build the LessTif libraries yourself, the following slide provides guidelines for the same.

    • After the installation, any bugs in LessTif will need to be fixed

  • Building/Installing LessTif on Interix

    • Unzip the LessTif source code archive.

    • Download the latest config.guess and config.sub from ftp://ftp.gnu.org/ and replace the ones in the LessTif distribution.

    • Run the script 'configure' from the LessTif installation directory to create Makefile for current system

    • ./configure CFLAGS="-g –O2 –D_ALL_SOURCE"

    • make && make install

    • Any bugs in LessTif will need to be fixed

    • The bundled libraries have some fixes made in the code for the XmFileSelectionBox widget

  • Some of the bugs fixed in LessTif for:

    • Fixes made in the code for the XmFileSelectionBox widget for

      Not displaying . and .. Directories

    • The modified source code can be found in the file

      lib/Xm-2.0/FileSB.c and

      lib/Xm-2.0/LTglob.c

      under the LessTif installation directory

LessTif

LessTif is an open-source Motif library, which provides Motif Widget implementation for Motif 2.0. It is available at https://www.lesstif.org. It does mention support for Interix 3 2.2, however does not provide pre-compiled libraries for Interix, and no mention is made of Interix 3 3. At the end of this document, a zip file for LessTif Motif libraries version 0.92.32 is attached. You can use the attached file or download the latest source for LessTif and build it on Interix.

To install the zip file, ensure that you unzip it in C:. A directory C:\LessTif-0.92.32\ should get created and you should see 'include' and 'lib' directories under that. Then the LessTif libraries can be used in your Imakefile (or Makefile) as specified earlier in this document.

Issues in porting LessTif on Interix

If you want to build the LessTif libraries yourself, you must perform the following steps to ensure that theLessTif installation is completed successfully:

  1. Download the latest version of LessTif (ftp://ftp.lesstif.org/pub/hungry/lesstif/srcdist/lesstif-latest.tar.gz ) and place in the /tmp directory.

  2. Unzip and untar the files.

$ gunzip lesstif.tar $ tar xvf lesstif.tar

  1. Download the latest config.guess and config.sub files from ftp://ftp.gnu.org/pub/config and replace the existing ones in the top of the LessTif source directory, and the test subdirectory under it.

  2. Run the script 'configure' from the LessTif installation directory. You will need to add a flag to configure to ensure everything builds correctly. To run configure, type:

$ ./configure CFLAGS="-g –O2 –D_ALL_SOURCE"

This detects the settings in your system and creates the necessary Makefiles
  1. Once the configure script has completed, you can make LessTif and install it.

    $ make
     $ make install

Fix LessTif Bugs

After the installation of LessTif, any bugs in LessTif will need to be fixed. The libraries that are bundled with XmBrowser.zip have some fixes made in the code for the XmFileSelectionBox widget for the bugs that were noticed during the porting of the sample application. The modified source code can be found in the file lib/Xm-2.0/FileSB.c and lib/Xm-2.0/LTglob.c under the LessTif installation directory.

Sample Application – File Browser

  • File Browser application

  • The application uses X11, Xt and Motif libraries

  • The main function is to provide an User Interface to browse for the files specified under Unix directory representation, e.g, /usr/bin like /usr/bin under Interix

  • The X server is available on all Unix machines typically supplied by the operating system vendor

  • The xmbrowser.c uses the X11 and Xm libraries/files provided by X server on UNIX. Typically located under

/usr/include/X11R6/X11/ /usr/include/X11R6/Xm/

  • The application is compiled and built using the Makefile generated using the xmkmf utility as described before

  • The following slides provides guidelines for porting the application on Interix

  • Building the sample application on Interix

    • The application uses X11, Xt and Motif libraries

    • A zipped version of the application is provided along with this document, xmbrowser.zip.

    • Unzipping this file produces the files – xmbrowser.c and Imakefile

    • No code changes are done in the xmbrowser.c

    • Create the Makefile by running 'xmkmf' in Interix shell

    • There would be no errors generated and 'Makefile' is generated, timestamp of the file can be verified.

    • Run command 'make xmbrowser' on Interix shell, this creates the executable called 'xmbrowser'

    • 'make xmbrowser'also does not generate any compilation or linking errors

    • Run the X Server, Exceed or ReflectionX, on the host Windows NT machine(the one running Interix)

    • Run the executable from the DOS command prompt or the Interix shell. Remember to set DISPLAY variable explained before.

    • A file browser window pops up using the X server(already running in the host machine)

    • Browse for the files using the file selection box,

      • E.g in the file selection box type

        /usr/lib and

        see corresponding file list displayed, verify the same

Sample Application

The sample file browser application, which is attached at the end of this document, has been built using X11, Xt, and Motif libraries. The code for the application uses LessTif Motif libraries with the X11 libraries provided on Interix.

Building the same application on Interix

  • The application uses X11, Xt and Motif libraries

  • A zipped version of the application is provided along with this document, xmbrowser.zip.

  • Unzipping this file produces the files – xmbrowser.c and Imakefile

  • No code changes are done in the xmbrowser.c

  • Create the Makefile by running 'xmkmf' in Interix 3 shell

  • There would be no errors generated and 'Makefile' is generated, timestamp of the file can be verified.

  • Run command 'make xmbrowser' on Interix 3 shell, this creates the executable called 'xmbrowser'

  • 'make xmbrowser'also does not generate any compilation or linking errors

  • Building the sample application on Interix

  • The application uses X11, Xt and Motif libraries

  • A zipped version of the application is provided along with this document, xmbrowser.zip.

  • Unzipping this file produces the files – xmbrowser.c and Imakefile

  • No code changes are done in the xmbrowser.c

  • Create the Makefile by running 'xmkmf' in Interix 3 shell

  • There would be no errors generated and 'Makefile' is generated, timestamp of the file can be verified

This sample program (xmbrowse.exe) can be used to understand X-Windows programs, as well to verify working of X-Windows on Interix.

Unzipping this file produces the files – xmbrowser.c and Imakefile. To build this application, perform the following steps:

  1. Create the Makefile by running 'xmkmf' in Interix 3 shell.

  2. Type 'make xmbrowser'. This creates the executable called 'xmbrowser'.

LessTif Motif Library

The pre-compiled version of the LessTif X Motif library, for version 0.92.32 is included below. This zip file includes the header files and the Motif archive library. If you wish to compile your own version of LessTif, the current version can be downloaded and compiled using the instructions above.

Download the sample code (Lesstif.exe)

Unzipping the above file produces the following directories:

C:\lesstif\include – All the include files for Motif Widget classes

C:\lesstif\lib\Xm-2.0 – Contains libXm.a, the Motif archive library for Interix