[英]“X11/Xlib.h”: no such file or directory on mac os x mountain lion
我在編譯一個簡單程序時遇到了這個問題:
#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 ex.cpp -L / usr / X11R6 / lib -lX11”命令編譯該程序。
您可能需要通過以下方式將符號鏈接添加到X11文件夾:
須藤ln -s / opt / X11 / include / X11 / usr / local / include / X11
就我而言,我必須在usr/local
下創建include目錄。
您需要編譯:
g++ -o ex ex.cpp -I/usr/X11R6/include -L/usr/X11R6/lib -lX11
X11
標頭隨xQuartz
一起安裝,但您需要顯式引用它們
如果安裝xQuartz
它將安裝到/opt/X11
,而/usr/X11
和/usr/X11R6
是指向此位置的符號鏈接。
這個解決方案對我在Mavericks上的ruby-1.9.3-p362有效。
sudo ln -s /opt/X11/include/X11 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.