Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do I need to do to link with xlib?

Tags:

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.

like image 921
Jeffrey Aylesworth Avatar asked Dec 31 '09 01:12

Jeffrey Aylesworth


People also ask

How to use xlib in c++?

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.

What is X11 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.


2 Answers

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 
like image 110
Brian Campbell Avatar answered Oct 11 '22 13:10

Brian Campbell


$ 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.

like image 21
dmckee --- ex-moderator kitten Avatar answered Oct 11 '22 12:10

dmckee --- ex-moderator kitten