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 i
Presume he's using the tutorial from http://www.arcsynthesis.org/gltut/ along with 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
After which I could build glsdk_0.4.4 and examples without further issue.
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
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.)
#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;
}
(Source: LinuxGazette)
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.
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
Retry 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
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 :)