问题
I have a pretty basic X11 app that I run on Linux that I'm trying to get compiled under OSX 10.5.8. I have X11 and the X11 SDK installed, and modified the makefile as follows:
CFLAGS = -L/usr/X11/lib -I/usr/X11/include
Everything compiles fine, but the linker can't find the X11 lib.
ld: library not found for -lX11
I've looked on google, but the only other people I've found with this problem so far either didn't have the X11 SDK installed or didn't know about the -L flag.
Any ideas?
回答1:
You may be looking in the wrong location for the library; it's certainly in a different location on my OS X box. Try typing:
locate libX11.dylib
and adding an appropriate path. E.g. on my system you'd need -L/usr/X11/lib/
in you CFLAGS.
回答2:
gcc SimpleXlibApp.c -o SimpleXlibApp -lX11 -L/usr/X11/lib -I/usr/X11/include
That line compiles the example here: http://en.wikipedia.org/wiki/Xlib
回答3:
-L/usr/X11/lib doesn't work with OSX 10.6 and it 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
来源:https://stackoverflow.com/questions/4047680/ld-cant-find-x11-library-on-osx-leopard