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.
Xlib is a library that allows you to draw graphics on the screen of any X server, local or remote, using the C language. All you need to do is include <X11/Xlib. h>, link your program using the -lX11 switch, and you are ready to use any of the functions in the library.
X11 Libraries. X11 is an implementation of the X Server, which provides display resources to other systems. X11 is distributed with the Solaris Operating System (OS). Add the directory in which X11 is installed to the LD_LIBRARY_PATH variable. If you are using Solaris 9 OS, you need X11R6.
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
$ locate libX11 /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/libX11.6.2.dylib /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/libX11.6.dylib /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/libX11.a /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/libX11.dylib /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libX11.6.2.0.dylib /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libX11.6.dylib /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libX11.dylib /usr/X11/lib/libX11.6.2.0.dylib /usr/X11/lib/libX11.6.dylib /usr/X11/lib/libX11.dylib /usr/X11/lib/libX11.la
I'd try
gcc [...] -L/usr/X11/lib -lX11 [...]
to set the search path for libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With