Skip to content

Instantly share code, notes, and snippets.

@jhollingworth
Last active January 4, 2018 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhollingworth/24c57fe654d5f9b591d577281c7992c4 to your computer and use it in GitHub Desktop.
Save jhollingworth/24c57fe654d5f9b591d577281c7992c4 to your computer and use it in GitHub Desktop.
Check X11
> sudo yum install libXext-devel libX11-devel xorg-x11-server-Xorg xorg-x11-server-Xvfb
> ls /usr/lib64 | grep X11
libX11.so
libX11.so.6
libX11.so.6.3.0
libX11-xcb.so
libX11-xcb.so.1
libX11-xcb.so.1.0.0
X11
> ls /usr/lib64 | grep libXext
libXext.so
libXext.so.6
libXext.so.6.4.0
// To compile: gcc x11-check.c -ldl -o x11-check
#include <dlfcn.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XShm.h>
int main()
{
void *libX11 = dlopen("libX11.so", RTLD_NOW | RTLD_LOCAL);
if (libX11) {
printf("libX11 exists\n");
void *libXext = dlopen("libXext.so", RTLD_NOW | RTLD_LOCAL);
if (libXext) {
printf("libXext exists\n");
} else {
printf ("libXext does NOT exist\n");
fprintf(stderr, "%s\n", dlerror());
return 1;
}
} else {
printf ("libX11 does NOT exist\n");
fprintf(stderr, "%s\n", dlerror());
return 1;
}
void *XOpenDisplay = dlsym(libX11, "XOpenDisplay");
if (XOpenDisplay) {
printf ("XOpenDisplay exists\n");
} else {
printf ("XOpenDisplay does NOT exist\n");
fprintf(stderr, "%s\n", dlerror());
}
return 0;
}
// > ./x11-check
// libX11 exists
// libXext exists
// XOpenDisplay exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment