# compiling basics nvcc

**URL:** <https://forums.developer.nvidia.com/t/compiling-basics-nvcc/33805>\
**Category:** CUDA Setup and Installation\
**Created:** [June 27, 2014, 6:14am UTC](https://forums.developer.nvidia.com/t/compiling-basics-nvcc/33805 "2014-06-27T06:14:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![agr\_saurav1](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@agr\_saurav1](https://forums.developer.nvidia.com/u/agr_saurav1)\
**Post date:** [June 27, 2014, 6:14am UTC](https://forums.developer.nvidia.com/t/compiling-basics-nvcc/33805/1 "2014-06-27T06:14:48Z")

</div>

System Intel i7 running Ubuntu 12.04  
Graphics information by deviceQuery

```auto
Device 0: "GeForce GTX 650"
  CUDA Driver Version / Runtime Version 6.0 / 6.0
  CUDA Capability Major/Minor version number: 3.0
  Total amount of global memory: 2048 MBytes (2147287040 bytes)
  ( 2) Multiprocessors, (192) CUDA Cores/MP: 384 CUDA Cores
  GPU Clock rate: 1058 MHz (1.06 GHz)

```

I am not able to compile my codes using nvcc. It gives an error

```auto
cc1plus: fatal error: cuda_runtime.h: No such file or directory
compilation terminated.

```

. I checked the Makefile provided in the samples and now I run

```auto
/usr/local/cuda-6.0/bin/nvcc

```

which works like a charm. Can someone explain why the former simple way did not work? How do I resolve this.

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [June 27, 2014, 1:07pm UTC](https://forums.developer.nvidia.com/t/compiling-basics-nvcc/33805/2 "2014-06-27T13:07:50Z")

</div>

You may have multiple copies of nvcc in different places on your system, and the error results when the wrong one is selected.

Do the following:

echo $PATH

which nvcc

find / -name nvcc \>out.txt

and provide the output of the first two commands along with the contents of out.txt created by the 3rd command.

---

<div class="post-metadata">

**Author:** ![agr\_saurav1](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@agr\_saurav1](https://forums.developer.nvidia.com/u/agr_saurav1)\
**Post date:** [June 27, 2014, 4:56pm UTC](https://forums.developer.nvidia.com/t/compiling-basics-nvcc/33805/3 "2014-06-27T16:56:52Z")

</div>

echo $PATH

```auto
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

```

which nvcc

```auto
<a target='_blank' rel='noopener noreferrer' href=''></a>/usr/local/bin/nvcc

```

find / -name nvcc \>out.txt

```auto
/home/saurav/.Mathematica/Paclets/Repository/CUDAResources-Lin64-9.0.0.0/CUDAToolkit/bin/nvcc
/usr/local/cuda-6.0/bin/nvcc
/usr/local/bin/nvcc

```

I had copied the nvcc file from /usr/local/cuda-6.0/bin/nvcc into the directory /usr/local/bin , so that I am able to run by simply using nvcc. I guess I should have rather added the directory to the path.

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [June 27, 2014, 5:02pm UTC](https://forums.developer.nvidia.com/t/compiling-basics-nvcc/33805/4 "2014-06-27T17:02:33Z")

</div>

Yes. Get rid of the copy in /usr/local/bin/nvcc

Update your PATH variable to include the proper CUDA path (the CUDA installer should have instructed you to do this, but if you used the package manager installation method then you would have to pay attention to the instructions in the linux getting started document.)

export PATH=/usr/local/cuda-6.0/bin:$PATH

edit your .bashrc or whatever method you wish to make it permanent.

---

<div class="post-metadata">

**Author:** ![agr\_saurav1](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@agr\_saurav1](https://forums.developer.nvidia.com/u/agr_saurav1)\
**Post date:** [June 27, 2014, 5:15pm UTC](https://forums.developer.nvidia.com/t/compiling-basics-nvcc/33805/5 "2014-06-27T17:15:02Z")

</div>

Yes. Works good.

Thanks
