Linux 在 Ubuntu 中找不到 X11/Xlib.h
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5299989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
X11/Xlib.h not found in Ubuntu
提问by Denys S.
I'm trying to write a rather trivial program using open gl on linux, but at a compile time it says:
我试图在 linux 上使用 open gl 编写一个相当简单的程序,但在编译时它说:
Compile thumb : egl <= cuberenderer.c In file included from /path/include/egl.h:36, from /path/cuberenderer.c:7: /path/include/eglplatform.h:89:22: error: X11/Xlib.h: No such file or directory /path/include/eglplatform.h:90:23: error: X11/Xutil.h: No such file or directory
编译拇指: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: 错误: X11/Xutil.h: 没有那个文件或目录
I'm totally new to GL and have no idea what's wrong.
我对 GL 完全陌生,不知道出了什么问题。
采纳答案by Andrew White
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?
打开包 libx11-dev 但你不应该需要它来进行纯 OpenGL 编程。你用的是什么教程?
You can add Xlib.h to your system by running the following...
您可以通过运行以下命令将 Xlib.h 添加到您的系统中...
sudo apt install libx11-dev
回答by Bob Smith
Presume he's using the tutorial from http://www.arcsynthesis.org/gltut/along with premake4.3 :-)
假设他正在使用http://www.arcsynthesis.org/gltut/ 中的教程以及 premake4.3 :-)
sudo apt-get install libx11-dev
................. forX11/Xlib.h
sudo apt-get install mesa-common-dev
........ forGL/glx.h
sudo apt-get install libglu1-mesa-dev
..... forGL/glu.h
sudo apt-get install libxrandr-dev
........... forX11/extensions/Xrandr.h
sudo apt-get install libxi-dev
................... forX11/extensions/XInput.h
sudo apt-get install libx11-dev
....... 为X11/Xlib.h
sudo apt-get install mesa-common-dev
...... 为GL/glx.h
sudo apt-get install libglu1-mesa-dev
.....GL/glu.h
sudo apt-get install libxrandr-dev
为X11/extensions/Xrandr.h
sudo apt-get install libxi-dev
..... .............. 为了X11/extensions/XInput.h
After which I could build glsdk_0.4.4and examples without further issue.
之后我可以构建glsdk_0.4.4和示例,而不会出现进一步的问题。
回答by Stokes
Andrew White's answer is sufficient to get you moving. Here's a step-by-step for beginners.
安德鲁怀特的回答足以让你感动。这是初学者的分步指南。
A simple get started:
一个简单的开始:
Create test.cpp: (This will be built and run to verify you got things set up right.)
创建 test.cpp :(这将被构建并运行以验证您是否设置正确。)
#include <X11/Xlib.h>
#include <unistd.h>
main()
{
// Open a display.
Display *d = XOpenDisplay(0);
if ( d )
{
// Create the window
Window w = XCreateWindow(d, DefaultRootWindow(d), 0, 0, 200,
100, 0, CopyFromParent, CopyFromParent,
CopyFromParent, 0, 0);
// Show the window
XMapWindow(d, w);
XFlush(d);
// Sleep long enough to see the window.
sleep(10);
}
return 0;
}
Try: g++ test.cpp -lX11
If it builds to a.out
, try running it.
If you see a simple window drawn, you have the necessary libraries, and some other root problem is afoot.
尝试:g++ test.cpp -lX11
如果它构建为a.out
,请尝试运行它。如果您看到一个简单的窗口被绘制出来,那么您就有了必要的库,并且还有一些其他的根本问题正在发生。
If your response is:
如果您的回答是:
test.cpp:1:22: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.
you need to install X11 development libraries.
sudo apt-get install libx11-dev
您需要安装 X11 开发库。
sudo apt-get install libx11-dev
Retry g++ test.cpp -lX11
重试 g++ test.cpp -lX11
If it works, you're golden.
如果它有效,你就是金子。
Tested using a fresh install of libX11-dev_2%3a1.5.0-1_i386.deb
使用全新安装的 libX11-dev_2%3a1.5.0-1_i386.deb 进行测试
回答by Zohaib Amanzai
Why not try find /usr/include/X11 -name Xlib.h
为什么不试试 find /usr/include/X11 -name Xlib.h
If there is a hit, you have Xlib.h
如果有命中,你有 Xlib.h
If not install it using sudo apt-get install libx11-dev
如果没有安装它使用 sudo apt-get install libx11-dev
and you are good to go :)
你很高兴去:)