You didn't include <X11/Xlib.h>.  Those other header files
don't include it, so perhaps improvised on the protoypes?
You should build with -Wall.

                Mark.

On 12 Jun 2003, Bill Baker wrote:

> Ever since I upgraded to Red Hat 9, I have been having problems
> compiling programs.  I tried searching the web, but have had no luck so
> far.  I have a custom build of XFree86 (4.3.0-3) installed that I built
> from the source RPM under Red Hat 8.0, however this problem did not
> start showing up until I upgraded to Red Hat 9.  The problem is that I
> keep getting "undefined reference" errors from certain X libraries. 
> Here is an example of a small C program I tried to compile just today
> under gcc-3.2.2-5:
> 
> #include <X11/extensions/XTest.h>
> #include <X11/keysym.h>
> 
> int main(void)
> {
>         Display* disp = XOpenDisplay(NULL);
>         if (disp == NULL) return 1;
>         XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Num_Lock),
> True,CurrentTime);
>         XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Num_Lock),
> False,CurrentTime );
>         XCloseDisplay(disp);
>         return 0;
> }
> 
> The command I used to compile it was:
> 
> gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o setnumlock numlock.c -lX11
> -lXtst
> 
> And the output was:
> 
> /tmp/ccNbDMZN.o(.text+0x16): In function `main':
> : undefined reference to `XOpenDisplay'
> /tmp/ccNbDMZN.o(.text+0x3c): In function `main':
> : undefined reference to `XKeysymToKeycode'
> /tmp/ccNbDMZN.o(.text+0x5f): In function `main':
> : undefined reference to `XKeysymToKeycode'
> /tmp/ccNbDMZN.o(.text+0x7c): In function `main':
> : undefined reference to `XCloseDisplay'
> /usr/X11R6/lib/libXtst.so: undefined reference to
> `XGetErrorDatabaseText'
> /usr/X11R6/lib/libXtst.so: undefined reference to `XPending'
> /usr/X11R6/lib/libXtst.so: undefined reference to `XextAddDisplay'
> /usr/X11R6/lib/libXtst.so: undefined reference to `XFree'
> /usr/X11R6/lib/libXtst.so: undefined reference to `XextFindDisplay'
> /usr/X11R6/lib/libXtst.so: undefined reference to `_XReply'
> /usr/X11R6/lib/libXtst.so: undefined reference to `_XDeqAsyncHandler'
> /usr/X11R6/lib/libXtst.so: undefined reference to `XextCreateExtension'
> /usr/X11R6/lib/libXtst.so: undefined reference to `_XGetAsyncData'
> /usr/X11R6/lib/libXtst.so: undefined reference to `_XEatData'
> /usr/X11R6/lib/libXtst.so: undefined reference to `_XFlush'
> /usr/X11R6/lib/libXtst.so: undefined reference to `_XSend'
> /usr/X11R6/lib/libXtst.so: undefined reference to `_XRead'
> /usr/X11R6/lib/libXtst.so: undefined reference to `XextRemoveDisplay'
> /usr/X11R6/lib/libXtst.so: undefined reference to `XMissingExtension'
> /usr/X11R6/lib/libXtst.so: undefined reference to `XQueryExtension'
> collect2: ld returned 1 exit status
> 
> Any ideas about what's going on?
> 
> --Bill
> 
> _______________________________________________
> XFree86 mailing list
> [EMAIL PROTECTED]
> http://XFree86.Org/mailman/listinfo/xfree86
> 

_______________________________________________
XFree86 mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xfree86

Reply via email to