" X11 / Xlib.h&QUOT ;:在Mac OS X山狮没有这样的文件或目录 [英] "X11/Xlib.h": no such file or directory on mac os x mountain lion

查看:1693
本文介绍了" X11 / Xlib.h&QUOT ;:在Mac OS X山狮没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到这个来的时候,我编写一个简单的程序:

I came across this when I was compiling a simple program:

 #include <X11/Xlib.h>
 #include <stdio.h>
 #include <stdlib.h>

 Display* display;

 int main(){
     display = XOpenDisplay("");
     if (display == NULL) {
         printf("Cannot connect\n");
         exit (-1);
     }
     else{
         printf("Success!\n");
         XCloseDisplay(display);
     }
  }

仅供参考,我已经安装了xQuartz。
我编译这个程序通过g ++ -o前ex.cpp -L在/ usr / X11R6 / lib目录-lX11命令。

FYI, I have xQuartz installed. I compile this program with "g++ -o ex ex.cpp -L/usr/X11R6/lib -lX11" command.

推荐答案

您需要编译:

g++ -o ex ex.cpp -I/usr/X11R6/include -L/usr/X11R6/lib -lX11

X11 头都安装了 xQuartz ,但你需要明确引用它们

the X11 headers are installed with xQuartz, but you need to reference them explicitly

如果您安装 xQuartz 它安装到的/ opt / X11 的/ usr / X11 的/ usr / X11R6 是符号链接到这个位置

If you install xQuartz it installs into /opt/X11, and /usr/X11 and /usr/X11R6 are symlinks to this location

这篇关于&QUOT; X11 / Xlib.h&QUOT ;:在Mac OS X山狮没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆