You need to tell the compiler what libraries to find the X11 functions in. The core X functions like XOpenDisplay
are in libX11, while extensions are in additional libraries - like libXext for XShmQueryVersion
.
The direct way to tell your compiler to link with these libraries is via -l
flags:
g++ myprogram.c -o program -lXext -lX11
Once you get to building larger software, with Makefiles & such, there are tools to help manage the flags for these libraries, and you might have something in your Makefile such as:
CFLAGS += `pkg-config --cflags x11 xext`
LIBS += `pkg-config --libs x11 xext`