在 Ubuntu 中找不到 X11/Xlib.h

我正在尝试用 linux 上的 open gl 编写一个相当简单的程序,但在编译时它说:

编译拇指: egl < = Cuberenderer.c 包含在 /path/include/egl.h: 36, 来自/path/Cuberenderer.c: 7: /path/include/eglplatform.h: 89:22: Error: X11/Xlib.h: 没有这样的文件或 目录 /path/include/eglplatform.h: 90:23: Error: X11/Xutil.h: 没有这样的文件或 目录

我对 GL 完全是个新手,不知道出了什么问题。

261591 次浏览

A quick search using...

apt search Xlib.h

Turns up the package libx11-dev but you shouldn't need this for pure OpenGL programming. What tutorial are you using?

You can add Xlib.h to your system by running the following...

sudo apt install libx11-dev

Presume he's using the tutorial from http://www.arcsynthesis.org/gltut/ along with premake4.3 :-)

sudo apt-get install libx11-dev ................. for X11/Xlib.h
sudo apt-get install mesa-common-dev........ for GL/glx.h
sudo apt-get install libglu1-mesa-dev ..... for GL/glu.h
sudo apt-get install libxrandr-dev ........... for X11/extensions/Xrandr.h
sudo apt-get install libxi-dev ................... for X11/extensions/XInput.h

After which I could build glsdk_0.4.4 and examples without further issue.

Why not try find /usr/include/X11 -name Xlib.h

If there is a hit, you have Xlib.h

If not install it using sudo apt-get install libx11-dev

and you are good to go :)