71

I am a complete Linux/Ubuntu noob, so I apologize for any dumb portions of this question or follow up ones.

I am trying to get a program that my software engineering class's group wrote onto my home computer. At school, we have Linux, and it will compile and run fine there. I downloaded VMWare, installed Ubuntu on a virtual machine, and now am trying to get my program to open.

When ever I try to run my make file however, I get an error that says

gcc -I../include -pthread -O1 -c rain.c
In file included from rain.c:19:0:
../include/GL/glfw.h:176:21: fatal error: GL/gl.h: No such file or directory
compilation terminated.
make: *** [rain.o] Error 1

Would anyone happen to know why it can't find this file, when it can on my school computers? And what I'd need to do to download it or get it in the right spot?

Braiam
  • 66,947
  • 30
  • 177
  • 264
Seldom
  • 813
  • 1
  • 7
  • 5

4 Answers4

111

I'd guess you don't have whatever dev package(s) provide gl.h. apt-file is the command line tool to use.

First, make sure it's up to date:

apt-file update

Now you can write a search to answer "what package provides the gl.h file?"

apt-file search "gl.h"

I don't have an ubuntu box just now to check, but I'd guess the result will be something like mesa-dev or opengl-dev.

Once you know what package provides "gl.h", (let's pretend the result from apt-file is "libmesa-dev"), install it:

apt-get install libmesa-dev

More info on the apt family of commands: https://help.ubuntu.com/community/AptGet/Howto

djeikyb
  • 29,665
  • 9
  • 55
  • 85
  • Thanks for the help. I tried what you suggested and updated the original post with the output of the search. – Seldom Jun 11 '13 at 08:13
  • Decided to just play around with it and downloaded the mesa-common-dev package. Then I managed to navigate to the usr/include/GL folder and found that it was there. I moved just copied/pasted it into my project's folder and it seemed to work. But then my project was giving an error that it needed a "glu.h" folder, so I downloaded the libcgal-dev package, and did the same thing with the copy/paste. After putting that in the correct folder, and running the make command, the project compiles and will run. So thank you very much for the help. Now I just need to get the graphics to slow down. :) – Seldom Jun 11 '13 at 08:41
  • Glad you got the build to work! Your copy/paste is the quick and dirty, but properly, your includes might be wrong. I don't know much c++, but had a similar problem compiling some package from source. Solution, iirc, was like changing `#include ` to `#include`. – djeikyb Jun 11 '13 at 16:00
  • The includes were like that. What it is that I was making was a GLFW program that had all the libraries and such in it from the tar file that I downloaded. I'm not sure why it didn't work, because it will on my school's computers. – Seldom Jun 12 '13 at 07:42
  • 26
    Oh, man thank you so much for teaching me to fish instead of just giving me the name of the package! – Brian Cain Aug 28 '13 at 00:22
  • apt-file is amazing! – protoss1210 Nov 06 '15 at 19:04
  • 3
    Thanks for the info on apt-file. Regarding the required package for GL/gl.h, it is: `mesa-common-dev` (at least for Ubuntu 16.04) – ElazarR Aug 17 '16 at 13:52
  • how do i delete the downloaded cache files after using apt-file.. to save space on server – dw1 Jul 10 '17 at 09:07
  • @dw1 that's a great question! if you don't see it already answered on askubuntu, you should [ask it yourself](https://askubuntu.com/questions/ask) – djeikyb Jul 10 '17 at 22:54
  • 1
    Give a man a fish and you feed him for one day, teach a man to fish and you feed him for a life time. Thank you! – Aras Jul 31 '17 at 15:14
  • 1
    +1 for the `apt-file`. BTW, to get only relevant replies we can use command `apt-file search "/usr/include/GL/gl.h"` – HEKTO Nov 27 '17 at 23:34
  • On Ubuntu 20.04: `sudo apt install libgl-dev` – wesinat0r Jun 29 '21 at 21:39
  • @wesinat0r I have rejected your edits twice now. They're not appropriate for this answer. Please consider instead amending [Richard's fine answer](https://askubuntu.com/a/866868/8515), or writing your own. – djeikyb Jun 30 '21 at 22:37
58

For GL/gl.h use:

sudo apt install mesa-common-dev

You may also find these helpful, for, say, GL/glu.h:

sudo apt install libglu1-mesa-dev freeglut3-dev
Richard
  • 1,327
  • 4
  • 17
  • 25
3

Ubuntu 20.04:

GL.h can be installed from the package libgl-dev.

sudo apt install libgl-dev

wesinat0r
  • 121
  • 1
  • 8
1

You can also build glproto (link), libdrm (link), and then mesa (link) from source. While many other packages may contain this header file, it's important to go to the source. This will reduce the memory footprint of your installations and ensure you have the latest and/or greatest version.