85

I'm trying to write a rather trivial program using open gl on linux, but at a compile time it says:

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

I'm totally new to GL and have no idea what's wrong.

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
Denys S.
  • 6,358
  • 12
  • 43
  • 65

3 Answers3

198

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
Community
  • 1
  • 1
Andrew White
  • 52,720
  • 19
  • 113
  • 137
  • apt-file gives no results, though libx11-dev is installed. I'm trying to adopt sources from chapter 5 of http://www.amazon.com/Pro-Android-Games-Vladimir-Silva/dp/1430226471/ref=sr_1_1?ie=UTF8&qid=1300113884&sr=8-1 to a simpler usage of ndk-build. – Denys S. Mar 14 '11 at 14:45
  • the thing is, that the chapter comes with two examples, a java based and a jni with c code. Java part works good, but I simply can't compile the c code. – Denys S. Mar 14 '11 at 14:49
  • Found it, it looks like apt-find was not completely working without a shell restart. Strange... – Denys S. Mar 14 '11 at 15:02
  • 1
    Thanks for not only telling which package to install but also pointing out how to solve similar problems in the future. – Frerich Raabe Aug 31 '16 at 12:24
  • Remember to execute an `apt-file update` before the actual search with that tool – Giuseppe Ricupero Sep 12 '17 at 07:09
  • Wow. Mind: blown. `apt-file search` is a game changer! – Chet Dec 01 '17 at 20:47
  • 2
    The last edit replaced `apt-file search` with `apt search` but in Ubuntu 18.04, `apt search` seems to only search packages (like `apt-cache`). Up to now I have only used `apt` as an improved `apt-get`/`apt-cache`. If `apt` alone doesn't work for you, try `apt-file`. – hsandt Jul 24 '18 at 12:37
  • I had "Xos.h: no such file or directory" error in compilation with Makefiles and this solved for me. – Marco Montevechi Filho Aug 22 '22 at 23:03
43

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.

Apache
  • 1,060
  • 5
  • 21
  • 38
Bob Smith
  • 431
  • 4
  • 2
  • You read my mind. I don't suppose you have the commands for the lgl libraries? :) EDIT: Nevermind, you answered that too - go build the glsdk_0.4.4! Thanks again! – NickO Jan 18 '14 at 06:27
5

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 :)

Zohaib Amanzai
  • 161
  • 2
  • 6