Later I knew that the error was due to Shared Object (SO) Name, also called soname, and its versoining.
When linking, the link editor (
ld) can take a library as parameter
via a link-library parameter (
-lGL). When it goes to look the library, it simply search the file by replacing l with lib and appending .so at the end of the link-library parameter. Now the parameter becomes libGL.so. However, it may not find exactly libGL.so and may find different versions like libGL.so.1, libGL.so.1.1 etc. This is the actual reason of my problem. Linker is looking for libGL.so but I only have libGL.so.1.
The quick solution of these type of problem is to symlink libGL.so.1 to libGL.so. This can be by using following Linux command
$ cd /usr/lib64
$ ln -s ./libGL.so.1 ./libGL.so
This may solve your problem.
Note : I have given the example of libGL.so but this trick works for all existing libraries. Use the trick accordingly.