OpenGL not Found, “cannot find -lGL”, and Other Issues with NVIDIA Drivers

Under Ubuntu,  sometimes when the NVIDIA drivers are installed, CMake cannot properly find OpenGL (specifically libGL.so). As a result, linking issues may occur.

The easiest fix for this is to first create a symlink of nvidia-current to nvidia-xxx where xxx is the version of the current NVIDIA driver installed (e.g. nvidia-387) . Then create a symlink from /usr/lib/libGL.so to /usr/lib/nvidia-current/libGL.so.

The command would be:

sudo ln -sfn /usr/lib/nvidia-xxx /usr/lib/nvidia-current
sudo ln -sfn /usr/lib/nvidia-current/libGL.so /usr/lib/libGL.so

Note that having nvidia-current symlink is generally a good idea as it can prevent other linker errors when it comes to finding NVIDIA-specific libraries. Also, remember to update this symlink whenever NVIDIA drivers are also updated.

Leave a Reply

Your email address will not be published.