Installing xdotool from source (missing XTest and other dependencies)

If you don’t know what xdotool is then this post is not for you…

Although many distros come with a packaged xdotool it is usually pretty old version (e.g. the one that comes wiht FC15 does not have the selectwindow command!) so you will most likely want to get the source tarball and install that. Download it from here.

– 1 –
After you untar and ‘make’ you will likely get some errors due to missing dependencies and due to Makefile referring to old include locations, with the first error most likely being:
  xdo.c:24:22: fatal error: X11/Xlib.h: No such file or directory

This most likely means that the X11 development lib is not installed (I said “most likely”, because even if it were – the xdotool Makefile is a bit broken as it refers to the old locations for the X11 libs. Read below how to fix that problem – for now we’ll be dealing with the possibly missing libs).

The missing lib is the X11 development lib. Depending on your distro it may be called e.g. libx11-dev (ubuntu), libX11-devel (fedora) or something similar. Use your package manager to install the lib and all dependencies that it says it needs. Make sure to install the DEVELOPMENT version of the library!

– 2 –
Now that libx11-dev is installed it’s time to fix the Makefile. Edit the Makefile and search for -L. You should see two lines that look like this:

 DEFAULT_LIBS=-L/usr/X11R6/lib -L/usr/local/lib -lX11 -lXtst -lXinerama
 DEFAULT_INC=-I/usr/X11R6/include -I/usr/local/include

As you can see the lib and include paths refer to the old location for X11 libs. Fix this by prepending the correct paths :
 DEFAULT_LIBS=-L/usr/lib/X11 -L/usr/X11R6/lib -L/usr/local/lib -lX11 -lXtst -lXinerama
 DEFAULT_INC=-I/usr/include/X11 -I/usr/X11R6/include -I/usr/local/include

– 3 –
Ok – now that we have the x11 lib and the paths are fixed lets ‘make’ again!
 xdo.c:28:34: fatal error: X11/extensions/XTest.h: No such file or directory
Damn! We need XTEST extensions… That one is a bit trickier as it may be found in all sorts of packages depending on the distribution.

To find it on ubuntu use: apt-file search XTest.h
On Fedora you can also find the package that contains a file (see my post on RPM files).

To make your life easier here’s that package name for FC and ubuntu:
Fedora Core: libXtst-devel
ubuntu: libxtst-dev (interestingly – Synaptic on xubuntu 11.04 was unable to find this package! I had to use apt-get install libxtst-dev to install this…)

– 4 –
Make again… Another error…
 xdo.c:29:37: fatal error: X11/extensions/Xinerama.h: No such file or directory

Won’t scare us, now that we know how to locate the missing file packages 😉
Install libXinerama-devel (libxinerama-dev) and you should be all set now!

– 5 –
make
make install
ldconfig

Done!

6 thoughts on “Installing xdotool from source (missing XTest and other dependencies)

Leave a Reply to ben Cancel reply

Your email address will not be published. Required fields are marked *