Can anyone tell me what this gcc compiler error is about?
gcc getfocuswindow.c
/tmp/ccRxQAIg.o: In function `main':
getfocuswindow.c
.text+0x26): undefined reference to `XOpenDisplay'
getfocuswindow.c
.text+0x64): undefined reference to `XGetInputFocus'
collect2: ld returned 1 exit status
The h files are located in /usr/include/X11. The libX11.so is in /usr/lib. Am I missing some environment variable or something?
The code being compiled is shown below:
// Written by John Brearley, 2006
// Returns the name of the currently focused Unix X11 window.
#include <stdio.h>
//#include <X11/Core.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
main()
{
char *display_name = NULL;
Display *display; //defined in Xlib.h
int i=1;
if (display=XOpenDisplay(display_name)) {
printf("OK\n");
} else {
printf("Failed\n");
}
i=XGetInputFocus(display,None,RevertToNone);
printf("i=%d\n",i);
}