Error compiling opengl code under Linux

If you have a NVidia card, you are using Linux and trying to compile something using Opengl, then you might have run into the following error:

Inconsistency detected by dl-version.c: 224: _dl_check_map_versions: Assertion `needed != ((void *)0)' failed!

This most probably happen to incosistency between NVidia and Mesa drivers for your card. It would be best to choose to use the NVidia drivers in most cases.
Go to directory usr/lib/nvidia-***
It could be nvidia-***-update or something like that. There should be a file there. You have to link it to your code. Remove -lGL from the other linker options.