What do I need to do to link with xlib?

Jeffrey Aylesworth picture Jeffrey Aylesworth · Dec 31, 2009 · Viewed 17.7k times · Source

I am using GCC, what switches do I need to add to link with Xlib? After searching, all I could find was -lX11, but that gave me ld: library not found for -lX11

I am using a mac (10.6), but I would not like anything that is Mac specific.

Answer

Brian Campbell picture Brian Campbell · Dec 31, 2009

You can usually use pkg-config to determine the flags you need to pass:

gcc my-program.c $(pkg-config --cflags --libs x11) -o my-program