/usr/bin/ld: cannot find -lnvcuvid

I’ve followed the steps of the NVIDIA CUDA Installation Guide and I’ve installed CUDA without warning or errors. Problems arrive when I try to compile the samples provided in the CUDA toolkit. Citing the dedicated section in the previous guide: “You should compile them by changing to ~/NVIDIA_CUDA-8.0_Samples and typing make”. The output, among other things, is:

/usr/bin/ld: cannot find -lnvcuvid

Related questions (http://askubuntu.com/questions/510176/usr-bin-ld-cannot-find-lcudart) and (http://stackoverflow.com/questions/16710047/usr-bin-ld-cannot-find-lnameofthelibrary) I checked whether lnvcuvid exists and apparently the file is missing.

$ ls /usr/local/cuda/lib64
libcublas_device.a     libcusparse_static.a  libnppisu.so
libcublas.so           libnppc.so            libnppisu.so.8.0
libcublas.so.8.0       libnppc.so.8.0        libnppisu.so.8.0.61
libcublas.so.8.0.61    libnppc.so.8.0.61     libnppitc.so
libcublas_static.a     libnppc_static.a      libnppitc.so.8.0
libcudadevrt.a         libnppial.so          libnppitc.so.8.0.61
libcudart.so           libnppial.so.8.0      libnpps.so
libcudart.so.8.0       libnppial.so.8.0.61   libnpps.so.8.0
libcudart.so.8.0.61    libnppicc.so          libnpps.so.8.0.61
libcudart_static.a     libnppicc.so.8.0      libnpps_static.a
libcufft.so            libnppicc.so.8.0.61   libnvblas.so
libcufft.so.8.0        libnppicom.so         libnvblas.so.8.0
libcufft.so.8.0.61     libnppicom.so.8.0     libnvblas.so.8.0.61
libcufft_static.a      libnppicom.so.8.0.61  libnvgraph.so
libcufftw.so           libnppidei.so         libnvgraph.so.8.0
libcufftw.so.8.0       libnppidei.so.8.0     libnvgraph.so.8.0.61
libcufftw.so.8.0.61    libnppidei.so.8.0.61  libnvgraph_static.a
libcufftw_static.a     libnppif.so           libnvrtc-builtins.so
libcuinj64.so          libnppif.so.8.0       libnvrtc-builtins.so.8.0
libcuinj64.so.8.0      libnppif.so.8.0.61    libnvrtc-builtins.so.8.0.61
libcuinj64.so.8.0.61   libnppig.so           libnvrtc.so
libculibos.a           libnppig.so.8.0       libnvrtc.so.8.0
libcurand.so           libnppig.so.8.0.61    libnvrtc.so.8.0.61
libcurand.so.8.0       libnppim.so           libnvToolsExt.so
libcurand.so.8.0.61    libnppim.so.8.0       libnvToolsExt.so.1
libcurand_static.a     libnppim.so.8.0.61    libnvToolsExt.so.1.0.0
libcusolver.so         libnppi.so            libOpenCL.so
libcusolver.so.8.0     libnppi.so.8.0        libOpenCL.so.1
libcusolver.so.8.0.61  libnppi.so.8.0.61     libOpenCL.so.1.0
libcusolver_static.a   libnppi_static.a      libOpenCL.so.1.0.0
libcusparse.so         libnppist.so          stubs
libcusparse.so.8.0     libnppist.so.8.0
libcusparse.so.8.0.61  libnppist.so.8.0.61

However, I don’t know where to safely get the file from so I’m stuck. For what it worths:
nvcc is already added in PATH.
In usr/local I have either cuda and cuda-8.0 folders, I not sure if this is normal.

the libnvcuvid.so is installed by the driver isntaller, not the toolkit installer.

Use a linux command (e.g. find) to locate the libnvcuvid.so on your machine. If you find it, it is apparently not on the linker search path, and you will need to fix that, either by adjusting the ld linker search path (it is not related to PATH nor is it related to LD_LIBRARY_PATH) or else make a copy of the libnvcuvid.so (or symlink) to a location that is on the linker search path (e.g. /usr/lib64).

If you cannot find libnvcuvid.so at all on your machine, then either you have not run the driver installer, or the driver install is broken.

If you are just creating a build machine, and this particular sample code is not terribly important to you, then stop beating yourself up and making your life difficult, and just ignore this particular build failure (if you don’t care about this particular sample code running correctly) and use:

make -k

You may want to read this question as well:

https://devtalk.nvidia.com/default/topic/769578/cuda-setup-and-installation/cuda-6-5-cannot-find-lnvcuvid/

I use nvidia-docker to setup a CUDA develop environment, also encounter the same issue. So I try to solve this issue and writing down a Dockerfile. Also adding some useful comments, hope it’ll be helpful.

Here is my Dockerfile:
https://github.com/allenyllee/server_setup/blob/master/nvidia_docker/Dockerfile

Also answered in there:
https://stackoverflow.com/a/46362272/1851492

# CUDA 8.0
#
# VERSION               0.0.1

FROM      nvidia/cuda:8.0-devel-ubuntu16.04
LABEL     maintainer="allen7575@gmail.com"

##
## Ubuntu - Packages - Search
## https://packages.ubuntu.com/search?suite=xenial&section=all&arch=amd64&searchon=contents&keywords=Search
##

###
### solve for
### >>> WARNING - libGL.so not found, refer to CUDA Getting Started Guide for how to find and install them. <<<
### >>> WARNING - libX11.so not found, refer to CUDA Getting Started Guide for how to find and install them. <<<
### >>> WARNING - Xlib.h not found, refer to CUDA Getting Started Guide for how to find and install them. <<<
### >>> WARNING - gl.h not found, refer to CUDA Getting Started Guide for how to find and install them. <<<
###
### 2_Graphics/volumeFiltering
### 2_Graphics/simpleGL
### 2_Graphics/bindlessTexture
### 2_Graphics/volumeRender
### 2_Graphics/Mandelbrot
### 2_Graphics/marchingCubes
### 2_Graphics/simpleTexture3D
### 3_Imaging/imageDenoising
### 3_Imaging/recursiveGaussian
### 3_Imaging/simpleCUDA2GL
### 3_Imaging/postProcessGL
### 3_Imaging/bicubicTexture
### 3_Imaging/boxFilter
### 3_Imaging/SobelFilter
### 3_Imaging/cudaDecodeGL
### 3_Imaging/bilateralFilter
### 5_Simulations/particles
### 5_Simulations/smokeParticles
### 5_Simulations/oceanFFT
### 5_Simulations/fluidsGL
### 5_Simulations/nbody
### 6_Advanced/FunctionPointers
### 7_CUDALibraries/randomFog
###
RUN apt update && apt -y install libgl1-mesa-dev

###
### solve for
### >>> WARNING - libGLU.so not found, refer to CUDA Getting Started Guide for how to find and install them. <<<
### >>> WARNING - glu.h not found, refer to CUDA Getting Started Guide for how to find and install them. <<<
### 
RUN apt update && apt -y install libglu1-mesa-dev

###
### solve for
### /usr/bin/ld: cannot find -lglut
### https://stackoverflow.com/questions/15064159/usr-bin-ld-cannot-find-lglut
###
RUN apt update && apt -y install freeglut3-dev

### 
### solve for
### >>> WARNING - egl.h not found, please install egl.h <<<
### >>> WARNING - eglext.h not found, please install eglext.h <<<
### >>> WARNING - gl31.h not found, please install gl31.h <<<
###
### 2_Graphics/simpleGLES_EGLOutput
### 2_Graphics/simpleGLES
### 2_Graphics/simpleGLES_screen
### 5_Simulations/nbody_opengles
### 5_Simulations/fluidsGLES
### 5_Simulations/nbody_screen
###
RUN apt update && apt -y install libgles2-mesa-dev

###
### You should also search 'UBUNTU_PKG_NAME = "nvidia-367"' and replace it to 'UBUNTU_PKG_NAME = "nvidia"' 
### for all matched files in the NVIDIA_CUDA-8.0_Samples folder to make it works.
###
RUN mkdir /usr/lib/nvidia && \
    ### solve for  /usr/bin/ld: cannot find -lnvcuvid \
    ### 3_Imaging/cudaDecodeGL \
    ln -s /usr/local/nvidia/lib64/libnvcuvid.so.1 /usr/lib/nvidia/libnvcuvid.so && \
    ### solve for >>> WARNING - libEGL.so not found, please install libEGL.so <<< \
    ### 3_Imaging/EGLStreams_CUDA_Interop \
    ln -s /usr/local/nvidia/lib64/libEGL.so.1 /usr/lib/nvidia/libEGL.so && \
    ### solve for >>> WARNING - libGLES.so not found, please install libGLES.so <<< \
    ### 2_Graphics/simpleGLES_EGLOutput \
    ### 2_Graphics/simpleGLES \
    ### 2_Graphics/simpleGLES_screen \
    ### 5_Simulations/nbody_opengles \
    ### 5_Simulations/fluidsGLES \
    ### 5_Simulations/nbody_screen \
    ln -s /usr/local/nvidia/lib64/libGLESv2_nvidia.so.2 /usr/lib/nvidia/libGLESv2.so

CMD    ["bash"]