Run into compiling errors, when compiling CUDA samples.

Hey guys I tried to compile several cuda samples which most of them failed. I tried several options including installing a bunch of packages and developer packages and using the option

GLPATH=/usr/lib make

.

System:

Linux ubuntu-workstation 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
 
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.26                 Driver Version: 375.26                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 460     Off  | 0000:01:00.0     N/A |                  N/A |
| 40%   49C    P0    N/A /  N/A |    377MiB /   958MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0                  Not Supported                                         |
+-----------------------------------------------------------------------------+

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Sep__4_22:14:01_CDT_2016
Cuda compilation tools, release 8.0, V8.0.44

System was installed with both binary CUDA and binary driver from the NVIDIA website. No package system was used.

One example: When i try to compile “nbody” I get the following error.

make
"/usr/local/cuda-8.0"/bin/nvcc -ccbin g++   -m64      -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o nbody bodysystemcuda.o nbody.o render_particles.o  -L/usr/lib/"nvidia-367" -lGL -lGLU -lX11 -lglut
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
Makefile:275: recipe for target 'nbody' failed
make: *** [nbody] Error 1

The make output for all samples can be found here:
https://paste.ubuntu.com/23795737/

Output before i installed the packages mentioned in the “WARNING” messages.
https://paste.ubuntu.com/23795770/

I hope that by having a look at the logs you may see something. If so please give me a hint in how to progress further. I am stuck at the moment. If you need any additional information, please ask i will provide it.

Thank You very much,
Hir I Mogul

This is your problem. Likely scenarios are:

(1) You don’t have libGL on your machine
(2) You have libGL on your machine, but you are not pointing the linker at the correct location vis the makefile settings: Check the -L flags generated by the makefile
(3) You have libGL on your machine, you have specified the correct path with a -L switch provided by the Makefile, but the filename is not quite right, e.g. you have libGL.so.1 on the machine, but the linker is looking for libGL.so (a symlink could fix this)

Note that this all about standard build managment, and has nothing to do with CUDA per se. As long as the above is your only error message, you should be able to build all CUDA examples that do not require OpenGL, which is actually quite a few.