Ld cannot find X11 library on OSX Leopard

I have a pretty basic X11 application that I run on Linux that I am trying to compile under OSX 10.5.8. I have the X11 and X11 SDK installed, and the makefile is modified as follows:

  CFLAGS = -L / usr / X11 / lib -I / usr / X11 / include 

Everything compiles fine, but the linker cannot find the X11 lib.

  ld: library not found for -lX11 

I looked at google, but only the other people I found with this problem until they installed the X11 SDK or did not know about the -L flag.

Any ideas?

+4
source share
3 answers

You may be looking for the wrong place for a library; this is of course elsewhere on my OS X box. Try typing:

locate libX11.dylib 

and adding the appropriate path. For instance. on my system you will need -L/usr/X11/lib/ in CFLAGS.

+2
source
 gcc SimpleXlibApp.c -o SimpleXlibApp -lX11 -L/usr/X11/lib -I/usr/X11/include 

This line compiles an example here: http://en.wikipedia.org/wiki/Xlib

+4
source

-L / usr / X11 / lib does not work with OSX 10.6 and has libX11.dylib:

 % ls -l /usr/X11/lib/libX11.* lrwxr-xr-x 1 root wheel 14 Jul 21 17:46 /usr/X11/lib/ libX11.6.2.0.dylib@ -> libX11.6.dylib -rwxr-xr-x 1 root wheel 3578368 Jul 12 2010 /usr/X11/lib/libX11.6.dylib* lrwxr-xr-x 1 root wheel 14 Jul 21 17:46 /usr/X11/lib/ libX11.dylib@ -> libX11.6.dylib 
+1
source

All Articles