解决 Xlib.h 找不到错误 Oct 13, 2015

[在线编辑]

缘由

相信,你也一定碰见过 Xlib.h 等文件找不到的情况,如何解决呢?给你一个通解:(此处仅针对 Mac OSX,其他平台也类似)

在 Mac OS X 平台,如果你安装了 xQuartz ,那么 Xlib.h 文件默认就在 /opt/X11/include/X11 目录,用 -I 指定目录,或者 ln 生成链接就好了。如果你不知道是否安装了 X11 ,那怎么办呢?其实,用 locate 查找就好了。


$ locate Xlib.h
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/Xlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Tk.framework/Versions/8.4/Headers/X11/Xlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/Xlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.4/Headers/X11/Xlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/Xlib.h
/System/Library/Frameworks/Tk.framework/Versions/8.4/Headers/X11/Xlib.h
/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/Xlib.h
/opt/X11/include/X11/Xlib.h
/opt/local/include/X11/Xlib.h

找一个目录创建链接,然后重新编译你的软件:


$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11

另一种解决办法,xcode-select 安装:


$ sudo xcode-select --install

扩展阅读

祝大家玩的开心

编程之道,就在[编程之美]

编程之美


标签: locate



请访问本站404页面,帮助妈妈找寻失散的宝贝!