idiot's question on Xlib programming
I write a simple program but can't compile it. Below is the program: #include Xlib.h main() {Display *d=XOpenDisplay(NULL); if(d==NULL) {printf(can't open display\n);exit(0);} XCloseDisplay(d); } I use gcc -I/usr/X11R6/include/X11 xhi.c to complie it and get the following message: /tmp/cca002281.o: In function `main': /tmp/cca002281.o(.text+0x9): undefined reference to `XOpenDisplay' /tmp/cca002281.o(.text+0x45): undefined reference to `XCloseDisplay' What's the problem? Please reply to [EMAIL PROTECTED] because I will leave the list in a minute.
Re: idiot's question on Xlib programming
On Tue, 3 Aug 1999 [EMAIL PROTECTED] wrote: I use gcc -I/usr/X11R6/include/X11 xhi.c to complie it and get the following message: /tmp/cca002281.o: In function `main': /tmp/cca002281.o(.text+0x9): undefined reference to `XOpenDisplay' /tmp/cca002281.o(.text+0x45): undefined reference to `XCloseDisplay' What's the problem? Please reply to [EMAIL PROTECTED] because I will leave the list in a minute. You have to link with Xlib, try adding the '-lX11' flag to your compile line. You may find Gtk or some other high-level toolkit less frustrating; Xlib is hard even if you have a lot of Unix programming experience. Havoc
Re: idiot's question on Xlib programming
[EMAIL PROTECTED] wrote: I write a simple program but can't compile it. Below is the program: #include Xlib.h> main() {Display *d=XOpenDisplay(NULL); if(d==NULL) {printf("can't open display\n");exit(0);} XCloseDisplay(d); } I use "gcc -I/usr/X11R6/include/X11 xhi.c" to complie it and get the following message: /tmp/cca002281.o: In function `main': /tmp/cca002281.o(.text+0x9): undefined reference to `XOpenDisplay' /tmp/cca002281.o(.text+0x45): undefined reference to `XCloseDisplay' What's the problem? Please reply to [EMAIL PROTECTED] because I will leave the list in a minute. -- Unsubscribe? mail -s unsubscribe [EMAIL PROTECTED] /dev/null You can try to compile with "gcc -I/usr/X11R6/include -L/usr/X11R6/lib/ -lX11 xhi.c" The source code is: #include X11/Xlib.h> main() {Display *d=XOpenDisplay(NULL); if(d==NULL) {printf("can't open display\n");exit(0);} XCloseDisplay(d); } It works on my computer -- \\\// / _ _ \ ( O O ) ===oOOO=(_)=OOOo=== PAQUET Ludovic e-mail : [EMAIL PROTECTED] telephone : 05-46-88-41-80 ===Oooo.=== .oooO ( ) ( ) ) / \ ( (_/ \_)
Re: idiot's question on Xlib programming
You need to link in the Xlib library with the switch -lX11. Martin From: [EMAIL PROTECTED] To: debian-user@lists.debian.org Subject: idiot's question on Xlib programming I write a simple program but can't compile it. Below is the program: #include Xlib.h main() {Display *d=XOpenDisplay(NULL); if(d==NULL) {printf(can't open display\n);exit(0);} XCloseDisplay(d); } I use gcc -I/usr/X11R6/include/X11 xhi.c to complie it and get the following message: /tmp/cca002281.o: In function `main': /tmp/cca002281.o(.text+0x9): undefined reference to `XOpenDisplay' /tmp/cca002281.o(.text+0x45): undefined reference to `XCloseDisplay' What's the problem? Please reply to [EMAIL PROTECTED] because I will leave the list in a minute. -- Unsubscribe? mail -s unsubscribe [EMAIL PROTECTED] /dev/null __ Get Your Private, Free Email at http://www.hotmail.com