Subject: Compiling a X app.
To: None <port-mac68k@netbsd.org>
From: =?ISO-2022-JP?B?GyRCRiNKLCEhNXwbKEI=?= <IZY01245@nifty.ne.jp>
List: port-mac68k
Date: 03/24/1999 12:27:20
Re: Compiling a X application
I can compile a normal C program using cc or gcc on my NetBSD, but cannot a
X program. When I tried to make a program, I got these error messages below.
I had installed Xbase.tgz and Xcomp.tgz, checked the contents of /etc/ld.so.
conf to find the '/usr/X11R6/lib' entry and softlinked /usr/X11R6/include/X11
to /usr/include/X11 in advance. I guess linking didn't succeed, but I don't
know why. I appreciate your advice.
/var/tmp/cc00214a1.o: Undefined symbol '_XOpenDisplay' referenced from text se
gment
/var/tmp/cc00214a1.o: Undefined symbol '_XCreateSimpleWindow' referenced from
text segment
/var/tmp/cc00214a1.o: Undefined symbol '_XSetStandardProperties' referenced fr
om text segment
/var/tmp/cc00214a1.o: Undefined symbol '_XSelectInput' referenced from text se
gment
/var/tmp/cc00214a1.o: Undefined symbol '_XMapWindow' referenced from text segm
ent
/var/tmp/cc00214a1.o: Undefined symbol '_XFlush' referenced from text segment
/var/tmp/cc00214a1.o: Undefined symbol '_XNextEvent' referenced from text segm
ent
/var/tmp/cc00214a1.o: Undefined symbol '_XCloseDisplay' referenced from text s
egment
(This is the source code.)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
main()
{
Display *disp; /* conn to X server */
Window win; /* windows */
static char window_name[] = "Hello !";
if ((disp = XOpenDisplay(NULL)) == NULL) {
fprintf(stderr,
"cannot connect to X server.\n");
exit(-1);
}
/* Request for creating a window */
win = XCreateSimpleWindow(disp, RootWindow(disp, 0),
0, 0, 300, 300, 2,
BlackPixel(disp, 0),
WhitePixel(disp, 0));
XSetStandardProperties(disp, win, window_name,
NULL, NULL, NULL /* argv */ , 0 /* argc */ , NULL);
XSelectInput(disp, win, ButtonPressMask);
XMapWindow(disp, win);
XFlush(disp);
/* Event Handling Loop */
while (1) {
XEvent report;
XNextEvent(disp, &report);
if (report.type == ButtonPress) {
switch (((XButtonEvent *) & report)->button) {
case Button1:
printf("Left button pressed.\n");
break;
case Button3:
printf("Right button pressed.\n");
printf("Now Closing Connection.\n");
XCloseDisplay(disp);
return 0;
default:
break;
}
}
}
}
--
Robert