https://stackoverflow.com/questions/15779181/using-x11-in-osx-10-8-3-ld-library-not-found-for-lx11

 

 

lazarus 注意问题
this line in this makefile LIBDIR = -L/usr/X11/lib -L/usr/X11R6/lib

应该把usr/X11 搜索这个目录。 然后找到x11 x11r6 这两个目录然后将其添加到path 环境变量里面

前提是安装 XQuartz
相关文章在这个网址https://stackoverflow.com/questions/15779181/using-x11-in-osx-10-8-3-ld-library-not-
found-for-lx11

真实折磨啊

 

I have the following makefile:

PROG    = draw
CFLAGS  = -w -s -O2 -ansi -DSHM
XLIBS   = -lX11 -lXext -lXmu -lXext -lXmu -lXt -lXi -lSM -lICE
LIBS    = -framework OpenGL
INCLS   = -I/usr/X11R/include -I/share/mesa/include
LIBDIR  = -L/usr/X11/lib -L/usr/X11R6/lib
#source codes
SRCS = draw_main.cpp $(PROG).cpp
#substitute .cpp by .o to obtain object filenames
OBJS = $(SRCS:.cpp=.o)

#$< evaluates to the target's dependencies,
#$@ evaluates to the target

$(PROG): $(OBJS)
    g++ -o $@ $(OBJS)  $(LIBDIR) $(LIBS) $(XLIBS)

$(OBJS):
    g++ -c  $*.cpp $(INCLS)

clean:
    rm $(OBJS) 

Every time I try to run it, I get the following error:

ld: library not found for -lX11
collect2: ld returned 1 exit status

Can someone please help me find out where the library for X11 is supposed to be in OSX 10.8.3? To me, this looks correct.

Thanks in advance.

shareimprove this question
 
  •  
    I should add, the line: LIBS = -framework OpenGL used to be XLIBS = -lX11 -lXext -lXmu -lXext -lXmu -lXt -lXi -lSM -lICE, but that gave me even more errors in OSX (though it worked just fine in Linux) and I read I should use framework OpenGL instead. – UndefinedReference Apr 3 '13 at 4:59 
  •  
    Have you looked for libX11.so or libX11.a in /usr/X11/lib? – parkydr Apr 3 '13 at 11:44
  •  
    @parkydr : I just did right now and I honestly can't see that file. Is something missing from my X11 installation? – UndefinedReference Apr 3 '13 at 20:46
  • 1
    Maybe, except the header files must be there. The include line looks weird (-I/usr/X11R/include -I/share/mesa/include) it might be worth trying /share/mesa/lib or /usr/X11R/lib. – parkydr Apr 3 '13 at 20:53
  •  
    mesa was here INCLS = -I/usr/X11R6/include -I/usr/X11/include/GL, just in case you were curious. Thank you. – UndefinedReference Apr 4 '13 at 3:43
 

Have you installed XQuartz, as suggested here: http://support.apple.com/kb/HT5293 ?

By default there is no X11 on Mountain Lion.

shareimprove this answer
 
  • 1
    It comes with XCode. But yeah, I installed it just now. Now it's telling me that the "symbols are not recognized in x86 64 architecture"...meaning I've screwed things up even worse...basically I'm wondering what file I'm supposed to be looking for to link in the makefile, to get this thing running. – UndefinedReference Apr 3 '13 at 21:17
  •  
    XCode and X11 are two completely different things. If you want to build a unix program based on X11 on Mountain Lion you need to first install XQuartz. I think you can build it in 32 bits or 64 bits mode or both. You need to read about the stuff carefully, I'm afraid. – piokuc Apr 3 '13 at 21:23
  •  
    Really? Because it looked like X11 was an optional install in XCode and the folders are there for me. However, I still appreciate your help and am wondering if, after installing XQuartz, do I just have to change this line in this makefile LIBDIR = -L/usr/X11/lib -L/usr/X11R6/lib to whatever location XQuartz puts the X11 folder in? Thank you. – UndefinedReference Apr 3 '13 at 21:55
  •  
    That's exactly what I would try. – piokuc Apr 3 '13 at 21:57
  • 1
    I had to change this line '#LIBS = -framework OpenGL' back to this 'LIBS = -lglut -lGLU -lGL' and this one #INCLS = -I/usr/X11R/include -I/share/mesa/include' to this one INCLS = -I/usr/X11R6/include -I/usr/X11/include/GL`. – UndefinedReference Apr 4 '13 at 3:42
 

Your Answer