newbie xhello.c question

Harold L Hunt II huntharo@msu.edu
Sun Sep 28 04:58:00 GMT 2003


David,

Your Imakefile needs only the following changes:

LOCAL_LIBRARIES = $(XAWLIB) $(XPMLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
[Added XPMLIB]


PROGRAMS = ProgramTagetName(xhello)
[Added ProgramTargetName]


The problem was that the build rule for xhello was different than 
xhello.exe, but xhello didn't have the proper link rule.

You can check this out before modifying your Imakefile by running 'make 
xhello.exe' instead of 'make xhello' or 'make'.  Then you will get the 
link warning about XPM, which can be fixed by modifying your Imakefile 
as above.


Good luck,

Harold

David Andersen wrote:
> (apologies if this is a duplicate post - I originally posted at 11:30 AM,
> and
> haven't seen it come thru yet)
> 
> I've just downloaded cygwin and am trying to get an Xwidget hello program
> to compile + run.
> 
> With the following Imakefile and xhello.c, I get the following when I do
> "xmkmf", "make".   Is there something I haven't set up?
> 
> $ make
> gcc   xhello.o      -o xhello
> xhello.o(.text+0x65):xhello.c: undefined reference to `_XtVaAppInitialize'
> xhello.o(.text+0x70):xhello.c: undefined reference to `_labelWidgetClass'
> xhello.o(.text+0x88):xhello.c: undefined reference to
> `_XtVaCreateManagedWidget'
> xhello.o(.text+0x90):xhello.c: undefined reference to `_XtRealizeWidget'
> xhello.o(.text+0x9b):xhello.c: undefined reference to `_XtAppMainLoop'
> collect2: ld returned 1 exit status
> make: *** [xhello] Error 1
> 
> ------------- Imakefile ---------------------------------
> 
> LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
>            SRCS = xhello.c
>            OBJS = xhello.o
>        PROGRAMS = xhello
> 
> all::  $(PROGRAMS)
> 
> ComplexProgramTarget(xhello)
> 
> ------------- xhello.c  ---------------------------------
> /*
>  * xhello.c - simple program to put up a banner on the display
>  */
> 
> /*
>  * Include files required for all Toolkit programs
>  */
> #include <X11/Intrinsic.h>     /* Intrinsics Definitions*/
> #include <X11/StringDefs.h>    /* Standard Name-String definitions*/
> 
> /*
>  * Public include file for widgets we actually use in this file.
>  */
> #include <X11/Xaw/Label.h>     /* Athena Label Widget */
> 
> main(argc, argv)
> int argc;
> char **argv;
> {
>  XtAppContext app_context;
>     Widget topLevel, hello;
> 
>     topLevel = XtVaAppInitialize(
>         &app_context,       /* Application context */
>         "XHello",         /* Application class */
>         NULL, 0,            /* command line option list */
>         &argc, argv,        /* command line args */
>         NULL,               /* for missing app-defaults file */
>         NULL);              /* terminate varargs list */
> 
>  hello = XtVaCreateManagedWidget(
>   "hello",   /* arbitrary widget name */
>   labelWidgetClass, /* widget class from Label.h */
>   topLevel,   /* parent widget */
>         NULL);              /* terminate varargs list */
> 
>  /*
>   *  Create windows for widgets and map them.
>   */
>  XtRealizeWidget(topLevel);
> 
>  /*
>   *  Loop for events.
>   */
>  XtAppMainLoop(app_context);
> }
> 
> 
> 
> 



More information about the Cygwin-xfree mailing list