I'm on ubuntu 18.04 and when I run on the terminal:

g ++ opengl_test.cpp -o firstOpenGlApp -lglut -lGLU -lGL

I have this error:

/usr/bin/ld: can not find -lGL

if anyone could help me I thank you in advance.


You are missing the libGL.so library. Fix by installing the libgl1 package:

sudo apt-get install libgl1


  • libgl1 is a vendor neutral GL library. Alternatively, you could install libgl1-mesa-dev, which is an OpenGL implementation, and also provides libGL.so.
  • When using the -l linker (/usr/bin/ld) option for specifying a library, the lib file prefix and .so suffix are omitted. Therefore, with -lGL we tell the linker to link against the libGL.so shared object.
  • If you're unsure as to which package provides the library you need, try to look it up in Ubuntu's package search: https://packages.ubuntu.com/search?suite=bionic&arch=any&mode=filename&searchon=contents&keywords=libGL.so.1
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.