|
有如下一段代码,用
gcc -o hellowold hellowld.c -lX11 -lXm -lXt
编译出错误:
/usr/bin/ld: cannot find -lX11
collect2: ld returned 1 exit status
我用redhat9,完全安装,相应得库肯定是装了的。
请问是怎么回事?
谢谢
代码如下:
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/XmAll.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
void activateCB();
XmString btn_text;
int main(argc,argv)
unsigned int argc;
char **argv;
{
Widget toplevel;
Widget myform;
Widget mylabel;
Widget mybutton;
XtAppContext app_context;
Arg args[10];
int i;
toplevel=XtAppInitialize(&app_context,"Xmdemos",NULL,0,&argc,argv,NULL,NULL,0);
i=0;
XtSetArg(args,XmNwidth,160);i++;
XtSetArg(args,XmNheight,100);i++;
myform=XtCreateManagedWidget("Form",xmFormWidgetClass,toplevel,args,i);
btn_text=XmStringCreateLtoR("Exit",XmSTRING_DEFAULT_CHARSET);
i=0;
XtSetArg(args,XmNlabelString,btn_text);i++;
XtSetArg(args,XmNheight,30);i++;
XtSetArg(args,XmNtopAttachment,XmATTACH_FORM);i++;
XtSetArg(args,XmNleftAttachment,XmATTACH_FORM);i++;
XtSetArg(args,XmNrightAttachment,XmATTACH_FORM);i++;
mybutton=XtCreateManagedWidget("button",xmPushButtonWidgetClass,myform,args,i);
btn_text=XmStringCreateLtoR("Hello World!",XmSTRING_DEFAULT_CHARSET);
i=0;
XtSetArg(args,XmNlabelString,btn_text);i++;
XtSetArg(args,XmNtopWidget,mybutton);i++;
XtSetArg(args,XmNtopAttachment,XmATTACH_WIDGET);i++;
XtSetArg(args,XmNleftAttachment,XmATTACH_FORM);i++;
XtSetArg(args,XmNrightAttachment,XmATTACH_FORM);i++;
XtSetArg(args,XmNbottomAttachment,XmATTACH_FORM);i++;
mylabel=XtCreateManagedWidget("Hello",xmLabelWidgetClass,myform,args,i);
XtAddCallback(mybutton,XmNactivateCallback,activateCB,NULL);
XtRealizeWidget(toplevel);
XtAppMainLoop(app_context);
return 1;
}
void activateCB(w,client_data,call_data)
Widget w;
caddr_t client_data;
caddr_t call_data;
{
printf("PushButton selected.\n");
XmStringFree(btn_text);
exit(0);
} |
|