" 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