Skip to content


tk fails on 10.8 with ld: library not found for -lX11 #15222

pzingg opened this Issue · 9 comments

5 participants

  1. installed Xcode 4.5 and command line tools
  2. brew install apple-gcc42
  3. put /usr/local/bin first on path, so brew doctor doesn't complain
  4. installed XQuartz 2.7.4

There is a valid libX11 at /opt/X11/lib (which is also symlinked from /usr/X11R6/lib:

file /opt/X11/lib/libX11.dylib 
/opt/X11/lib/libX11.dylib: Mach-O universal binary with 2 architectures
/opt/X11/lib/libX11.dylib (for architecture i386):  Mach-O dynamically linked shared library i386
/opt/X11/lib/libX11.dylib (for architecture x86_64):    Mach-O 64-bit dynamically linked shared library x86_64

But link fails:

brew: superenv removed: -Os -I/usr/local/include -L/opt/X11/lib -arch x86_64 -L/usr/X11R6/lib
ld: library not found for -lX11
collect2: ld returned 1 exit status
make: *** [libtk8.5.dylib] Error 1

Error: tk did not build```

Link part of 02.make file is at


What formula are you trying to compile? We don't have a Tk formula in core.


It's from homebrew-dupes, I guess. I don't really need tk. Was able to compile ruby 1.8.7 with

rvm install 1.8.7 --without-tk
@pzingg pzingg closed this
@pzingg pzingg reopened this
Homebrew member

We'd prefer you report this against homebrew-dupes, but never mind.

Homebrew member

Testing: --without-x configure option.


Hello. I am having a similar issue with 10.7. Installing Tk results in

brew: superenv removed: -Os -I/usr/local/include -arch x86_64 -L/usr/X11R6/lib
ld: library not found for -lX11

I do need Tk, so I cannot circumvent this problem with a --without-x solution.

I do have valid X11 installations in /usr/X11 and /usr/X11R6. They are used by Matlab I think, so I am unsure of what happens if I mess around with these installations (I am not sure of what I am saying, because X11 comes also in a framework, but I dont-t quite understand all this).

Thanks for help or hints -- or for redirecting me somewhere else!


Hi it-s me again. I provide the output of --config command FYI (and where X11 seems to be OK...):

picadestats:usr jsola$ brew --config
HEAD: f14b572
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: dual-core 64-bit core2
OS X: 10.7.5-i386
Xcode: 4.5
LLVM-GCC: build 2336
Clang: 4.1 build 421
X11: 2.6.4 => /usr/X11
System Ruby: 1.8.7-358
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Thank you.


Sorry, I'll try to create a proper Ticket for my issue before going on. I just realised it too late. I'm sincerely sorry.



@adamv adamv closed this

As a temporary work around, you can enter in your shell before the brew command:

  export CPPFLAGS=-I/opt/X11/include
  brew install tk

The export line will tell the compile/linker to look in /opt/X11/include for the X11 include files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.