When using homebrew to install graphviz, the script gets to the point of "Making install in tkstubs" and then throws the following fatal error:
In file included from tkStubLib.c:15:
/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
I have installed XQuartz as X11 has been dropped in Mountain Lion, but I'm unsure if it is installed correctly. The location of Xlib.h is:
/opt/X11/include/X11/Xlib.h
There are also two symlinks to /opt/X11, they are:
/usr/X11
/usr/X11R6
Does this look like the correct setup to you? I've never dealt with X11 or XQuartz until yesterday.
Cheers.
You need to tell the tkstubs
build (and possibly other bits in the package as well) to look for headers in /opt/X11/include
; this is not on the standard include path.
Usually this is achieved by passing -I/opt/X11/include
as an additional compiler flag, the method to do so is however dependent on the build system.
For reasonably modern configure
scripts, the best approach is to pass it in the environment variable CPPFLAGS
; if the package uses another build system or this doesn't work for another reason, then you need to look at the Makefile
in the build directory.
After installing XQuartz you may add a symlink to your X11 installation folder by just entering
ln -s /opt/X11/include/X11 /usr/local/include/X11
in terminal. That will fix the problem as well without changing any ruby script.
You can enter in your shell before the compile/link (or brew) command:
export CPPFLAGS=-I/opt/X11/include
The export line will tell the compile/linker to look in /opt/X11/include for the X11 include files
Had the same issue and running this command on terminal
xcode-select --install
worked for me. Run this command after installing xQuartz.
If you need this to work in your CMake builds:
if(APPLE)
include_directories(AFTER "/opt/X11/include")
endif()
That worked well for me.
I got it to install by copying the x11 header file directory to the /opt/local/include directory. Probably not the best way to work around it but quick and easy.
Since the make file is looking for X11/xlib.h i.e., it is looking for X11 folder in the current directory, one way to solve this problem is to simply copy the /opt/X11/include/X11 directory to the directory that contains make file.
I found this thread while trying to compile ffmpeg from source on OS X. I needed --enable-x11grab
and the homebrew build does not support this option.
I had XQuartz installed already but I kept getting errors from ./configure
: ERROR: Xlib not found
. I thought the answers here would solve my problem, but they did not!
So, if anyone is ever in the same boat, my solution was this:
I opened up the generated config.log
and found lots of errors referring to various includes and header files, including X11/Xlib.h - this is misleading. At the very bottom of the logfile was the key, pkg-config
was complaining about looking for xbc.pc
, and requested that it be put on the path. However, the error message that is displayed on the terminal says nothing about pkg-config
or xbc
!
The solution is to add to your PKG_CONFIG_PATH
environment variable. Mine was nonexistent, so I just did export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/
(the folder where I found xbc.pc
).
I reran configure
and everything worked like a charm!
TL;DR: check config.log - don't trust the terminal output!
来源:https://stackoverflow.com/questions/11465258/xlib-h-not-found-when-building-graphviz-on-mac-os-x-10-8-mountain-lion