[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Compiling simple Motif/Lesstif programs.



What command-line options do I use? Let's take this program:

#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/Label.h>

int main(int argc, char *argv[])
{
	Widget toplevel, msg;
	Arg al[10];
	int ac;

	toplevel = XtInitialize(argv[0], "", NULL, 0, &argc, argv);
	ac = 0;
	XtSetArg(al[ac], XmNlabelString,
		 XmStringCreate("foo!!", XmSTRING_DEFAULT_CHARSET)); ac++;
	msg = XtCreateManagedWidget("msg",xmLabelWidgetClass, toplevel, al,
ac);
	XtRealizeWidget(toplevel);
	XtMainLoop();

	return 0;
}

I'm trying to compile it like so:

bash-2.01$ cc -o foo foo.c -I/usr/X11R6/include
/tmp/ccc06235: In function `main':
/tmp/ccc06235(.text+0x1f): undefined reference to `XtInitialize'
/tmp/ccc06235(.text+0x44): undefined reference to `_XmStrings'
/tmp/ccc06235(.text+0x49): undefined reference to `_XmStrings'
[rest snipped]

I'm pretty sure I'm missing some linker flags, but -lX11, -lXm and
others give me: ld: cannot open -lX11:  No such file or directory

I'm using the latest lesstifg package and latest xlib6g-dev. What else
do I need? It's 3am, I give up.

Christopher
PS - been learning to use GTK and everything compiles flawlessly.


Reply to: