linux+安装视图界面xm,跨linux unix 平台界面开发库motif 开发环境配置

下载motif库

http://www.motifdeveloper.net/filebrowser/openmotif/2.2/2.2.2/linux-rpm/x86?sort=asc&order=Last+modified

#安装库[@more@]

跨linux unix 平台界面开发库motif 开发环境配置

下载motif库

http://www.motifdeveloper.net/filebrowser/openmotif/2.2/2.2.2/linux-rpm/x86?sort=asc&order=Last+modified

#安装库

rpm -ivh libXp-1.0.0-8.1.el5.i386.rpm #安装X11R6库

rpm -ivh libXp-devel-1.0.0-8.1.el5.i386.rpm #安装X11R6开发库 --包括头文件

rpm -ivh openmotif22-2.2.2-5.i386.rpm #安装motif运行库

rpm -ivh openmotif-devel-2.2.2-5.i386.rpm #安装motif开发库 --包括motif 开发的头文件

#编辑home目录下的 .bash_profile

最后添加如下:

#添加motif运行时候用到的动态链接库路径

LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/X11R6/lib

export LD_LIBRARY_PATH

编写列子程序

helloworld.c

/* File: helloworld.c */

#include #include

void callback(Widget w, XtPointer client_data,

XmPushButtonCallbackStruct *cbs)

{

printf("Hello World!n");

}

int main(int argc, char *argv[])

{

int n;

Arg args[3];

XtAppContext app;

Widget toplevel, button;

XmString label;

//建立顶级窗口

toplevel = XtVaAppInitialize(&app, "HelloWorld", NULL, 0,

&argc, argv, NULL, NULL);

//建立按钮上标签的字符串

label = XmStringCreateSimple("Hello World!");

//建立按钮

n = 0;

XtSetArg(args[n], XmNlabelString, label); n++;

button = XmCreatePushButton(toplevel, "pushbutton", args, n);

XtManageChild(button);

XmStringFree(label);

//设置回调函数

XtAddCallback(button,

XmNactivateCallback, (XtCallbackProc)callback,

NULL);

//显示窗口

XtRealizeWidget(toplevel);

//进入事件循环

XtAppMainLoop(app);

}

编写Makefile如下

INCS = -I/usr/X11R6/include

LIBS = -L/usr/X11R6/lib -lXm -lXt -lX11 -lXp -lXext

all: helloworld

helloworld: helloworld.c

gcc -o helloworld helloworld.c $(INCS) $(LIBS)

clean:

rm -f helloworld *.bak

编译程序

make -f Makefile

编译成功

./helloworld

开发环境建立完毕

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值