Porting XWindows App

Hi,

I am having trouble porting an XWindows app and cannot get even a simple
xwin program to run. The one listed below gives a whole slew of
Warnings followed by an Error that crashes it.

Any ideas???

Simon


Warning: translation table syntax error: Unknown keysym name: osfHelp
Warning: … found while parsing ’ :osfHelp: Help()’
Error: attempt to add non-widget child “DropSiteManager” to parent
“./xtest” which supports only widgets

Makefile for Xwindows App

LDFLAGS= -L/usr/lib -L/usr/X11R6/lib -lm -lphexlib -lICE -lX11 -lXt -lXm
-lSM -lsocket
CFLAGS= -c -I…/include -I. -I/usr/X11R6/include -g -DQNX

xtest: xtest.o
gcc -o xtest xtest.o $(LDFLAGS)

xtest.o: xtest.c
gcc xtest.c $(CFLAGS)


////////////////// xtest.c
#include <stdio.h>
#include <Xm/Xm.h> /* Motif Toolkit */

void helloworld_activate(Widget widget, char *tag,
XmAnyCallbackStruct *callback_data);

Display *display;
XtAppContext app_context;

/*

  • Main program
    */
    int main(unsigned int argc, char *argv)
    {
    /
  • Declare the variables to contain the two widget ids
    */
    Widget toplevel, helloworldmain, helloworld = NULL;
    Arg arglist[1] ;
    int n;

XtToolkitInitialize();

app_context = XtCreateApplicationContext();

display = XtOpenDisplay(app_context, NULL, argv[0],
“helloworldclass”,
NULL, 0, &argc, argv);
if (display == NULL)
{
fprintf(stderr, “%s: Can’t open display\n”, argv[0]);
exit(1);
}

n = 0;
XtSetArg(arglist[n], XmNallowShellResize, True); n++;
toplevel = XtAppCreateShell(argv[0], NULL,
applicationShellWidgetClass,
display, arglist, n);

helloworldmain = XmCreateMainWindow(toplevel, “Mainw”, arglist,
0);

helloworld = XmCreatePushButton(helloworldmain, “Hello World”,
arglist, 0);
XtAddCallback(helloworld, XmNactivateCallback, helloworld_activate,
NULL);
XtManageChild(helloworld);

/*

  • Register our callback routines so that the resource manager can
  • resolve them at widget-creation time.
    */

/*

  • Make the toplevel widget “manage” the main window (or whatever
    the
  • the uil defines as the topmost widget). This will
  • cause it to be “realized” when the toplevel widget is “realized”
    */

XtManageChild(helloworldmain);

/*

  • Realize the toplevel widget. This will cause the entire
    “managed”
  • widget hierarchy to be displayed
    */

XtRealizeWidget(toplevel);

/*

  • Loop and process events
    */

XtAppMainLoop(app_context);

/* UNREACHABLE */
return (0);
}

void helloworld_activate(Widget widget, char *tag,
XmAnyCallbackStruct *callback_data)
{
Arg arglist[2];
static int call_count = 0;

call_count += 1 ;
switch ( call_count )
{
case 1:
XtSetArg( arglist[0], XmNlabelString,
XmStringLtoRCreate(“Goodbye\nWorld!”,""));
XtSetArg( arglist[1], XmNx, 11 );
XtSetValues( widget, arglist, 2 );
break ;
case 2:
exit(1);
break ;
}
}

Simon Wakley

In article <na9biBAHIL75EwwB@cameracontrol.com>,
Simon Wakley <Simon@cameracontrol.com> wrote:

Hi,

I am having trouble porting an XWindows app and cannot get even a simple
xwin program to run. The one listed below gives a whole slew of
Warnings followed by an Error that crashes it.

Any ideas???

Simon


Warning: translation table syntax error: Unknown keysym name: osfHelp
Warning: … found while parsing ’ :osfHelp: Help()’

All of the above are Motif(Lesstif) looking for the file
/usr/X11R6/lib/X11/XKeysymDB
Doesn’t matter in your case since you don’t need the keyboard :slight_smile:
I’ll try to include it in the next patch, meanwhile you can
grab one off the web.

Error: attempt to add non-widget child “DropSiteManager” to parent
“./xtest” which supports only widgets

I couldn’t bring myself to scan through the map files and
find out exactly what this is, but you simply need to
change the order of the libraries

LDFLAGS= -L/usr/lib -L/usr/X11R6/lib -lm -lphexlib -lICE -lX11 -lXt -lXm
-lSM -lsocket

Should be -lXm -lXt -lX11

BTW I find it much simpler with imake/xmkmf

//Imakefile

LOCAL_LIBRARIES = -lXm -lXt -lX11 -lSM -lICE
SimpleProgramTarget(xtest)

//end of Imakefile

then simply run xmkmf


Garry Turcotte (R&D)
QNX Software Systems, Ltd.

Great,

Fixed both problems.

Thanks very much for the quick and effective response! :slight_smile:

Simon

In article <8skd9e$bgq$1@nntp.qnx.com>, Garry Turcotte <garry@qnx.com>
writes

In article <> na9biBAHIL75EwwB@cameracontrol.com> >,
Simon Wakley <> Simon@cameracontrol.com> > wrote:
Hi,

I am having trouble porting an XWindows app and cannot get even a simple
xwin program to run. The one listed below gives a whole slew of
Warnings followed by an Error that crashes it.

Any ideas???

Simon


Warning: translation table syntax error: Unknown keysym name: osfHelp
Warning: … found while parsing ’ :osfHelp: Help()’

All of the above are Motif(Lesstif) looking for the file
/usr/X11R6/lib/X11/XKeysymDB
Doesn’t matter in your case since you don’t need the keyboard > :slight_smile:
I’ll try to include it in the next patch, meanwhile you can
grab one off the web.

Error: attempt to add non-widget child “DropSiteManager” to parent
“./xtest” which supports only widgets

I couldn’t bring myself to scan through the map files and
find out exactly what this is, but you simply need to
change the order of the libraries


LDFLAGS= -L/usr/lib -L/usr/X11R6/lib -lm -lphexlib -lICE -lX11 -lXt -lXm
-lSM -lsocket

Should be -lXm -lXt -lX11

BTW I find it much simpler with imake/xmkmf

//Imakefile

LOCAL_LIBRARIES = -lXm -lXt -lX11 -lSM -lICE
SimpleProgramTarget(xtest)

//end of Imakefile

then simply run xmkmf


Simon Wakley