/usr/bin/ld: cannot find -lGL collect2: error: ld returned 1 exit status

Hi,

I have installed cuda7.5 toolkit on ubuntu, I had to update these paths in the .bashrc file:

export LD_LIBRARY_PATH=/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin

all seems fine with the install, I am able to run most of the samples but I am trying to run some code that uses #include <GL/glut.h>, I have built the project using Nsight and have added the include path in the include paths but when I build it, I get the following errors:

Description Resource Path Location Type
make: *** [test1] Error 1 test1 C/C++ Problem
undefined reference to glClearColor' test.cu /test1 line 82 C/C++ Problem undefined reference to glDrawPixels’ test.cu /test1 line 47 C/C++ Problem
undefined reference to glutCreateWindow' test.cu /test1 line 79 C/C++ Problem undefined reference to glutDisplayFunc’ test.cu /test1 line 80 C/C++ Problem
undefined reference to glutInit' test.cu /test1 line 76 C/C++ Problem undefined reference to glutInitDisplayMode’ test.cu /test1 line 78 C/C++ Problem
undefined reference to glutInitWindowSize' test.cu /test1 line 77 C/C++ Problem undefined reference to glutKeyboardFunc’ test.cu /test1 line 81 C/C++ Problem
undefined reference to glutMainLoop' test.cu /test1 line 84 C/C++ Problem undefined reference to glutPostRedisplay’ test.cu /test1 line 59 C/C++ Problem
undefined reference to glutSwapBuffers' test.cu /test1 line 48 C/C++ Problem undefined reference to glutTimerFunc’ test.cu /test1 line 60 C/C++ Problem
undefined reference to `glutTimerFunc’ test.cu /test1 line 83 C/C++ Problem

I then thought i would try to compile in the terminal but got this error

nvcc -o test test.cu -lm -lGL -lglut

/usr/bin/ld: cannot find -lGL collect2: error: ld returned 1 exit status

any help is very much appreciated

mark

I have found an old article that I dont know if it is still relevant but despite the age of the post, it describes my problem almost exactly -

http://www.geeks3d.com/20111229/how-to-update-nvidia-graphics-drivers-under-linux/

[b]UPDATE: important note for developers: the graphics driver update breaks the symbolic link on the OpenGL lib. When you try to compile an OpenGL app, you get this message:

/usr/bin/ld: cannot find -lGL

To fix the link, jump to the libraries folder:

cd /usr/lib

If needed (because the ln command fails), delete the broken link:

sudo rm libGL.so

Now we can recreate the link with ln:

sudo ln -s libGL.so.1 libGL.so  [/b]

I have also installed Freeglut

sudo apt-get install freeglut3-dev

-I have tried the two other solutions but I am still getting:-

-----

/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status

-----