I came across this when I was compiling a simple program:
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
Display* display;
int main(){
display = XOpenDisplay("");
if (display == NULL) {
printf("Cannot connect\n");
exit (-1);
}
else{
printf("Success!\n");
XCloseDisplay(display);
}
}
FYI, I have xQuartz installed.
I compile this program with “g++ -o ex ex.cpp -L/usr/X11R6/lib -lX11” command.
you need to compile with:
the
X11headers are installed withxQuartz, but you need to reference them explicitlyIf you install
xQuartzit installs into/opt/X11, and/usr/X11and/usr/X11R6are symlinks to this location