/usr/bin/ld: cannot find -lcudart

tz@tz-dt:~/DSMC$ make
g++ -fPIC -o dsmcsg dsmcsg_main.o dsmcsg_class.o dsmcsg_init.o dsmcsg_output.o dsmcsg_readfile.o dsmcsg_cudafunction.o scanLargeArray_kernel.o -L/usr/local/cuda/lib64 -lcudart
/usr/bin/ld: cannot find -lcudart
collect2: ld returned 1 exit status
make: *** [dsmcsg] Error 1

what is -lcudart?
I can not find more info on Internet about it.
Need help to fix it.
Thanks a lot!

===================================================================================
deviceQuery & bandwidthTest is OK

tz@tz-dt:~/NVIDIA_CUDA-5.0_Samples/1_Utilities/deviceQuery$ ./deviceQuery ./deviceQuery Starting…
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: “GeForce GT 640” CUDA Driver Version / Runtime Version 5.0 / 5.0 CUDA Capability Major/Minor version number: 3.0
Total amount of global memory: 2047 MBytes (2146762752 bytes)
( 2) Multiprocessors x (192) CUDA Cores/MP: 384 CUDA Cores
GPU Clock rate: 1046 MHz (1.05 GHz)
Memory Clock rate: 900 Mhz
Memory Bus Width: 128-bit
L2 Cache Size: 262144 bytes
Max Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536,65536), 3D=(4096,4096,4096)
Max Layered Texture Size (dim) x layers 1D=(16384) x 2048, 2D=(16384,16384) x 2048
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Maximum sizes of each dimension of a block: 1024 x 1024 x 64
Maximum sizes of each dimension of a grid: 2147483647 x 65535 x 65535
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes
with 1 copy engine(s) Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): No
Device PCI Bus ID / PCI location ID: 2 / 0
Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 5.0, CUDA Runtime Version = 5.0, NumDevs = 1, Device0 = GeForce GT 640

tz@tz-dt:~/NVIDIA_CUDA-5.0_Samples/1_Utilities/bandwidthTest$ ./bandwidthTest
[CUDA Bandwidth Test] - Starting…
Running on…

Device 0: GeForce GT 640
Quick Mode
Host to Device Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 3135.3

Device to Host Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 2082.0

Device to Device Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 24312.5

1:“lcudart” ,it seems to be CUDA RUNTIME (library) something like this.
2:You can run deviceQuery and bandwitch Test successfully,that means your drivers,toolkit and all software environment are installed correctly.
3:I think you may reconfig your project to slove this problem,because CUDA 5.0 may change the path of the library.

Good luck!

please change “-L/usr/local/cuda/lib64” to “-L/usr/local/cuda-5.0/lib64”, then have a try

please make sure you installed cuda in /usr/local/cuda-5.0

抱歉楼主,我不用linux,所以无法理解此问题。

不过,我来多少说下可能的问题的可能所在:
你的gcc(ld)指定了命令行: -L/usr/local/cuda/lib64 -lcudart
然后接着报错:cannot find -lcudart

显然原因是在/usr/local/cuda/lib64(-L指定)下没有找到名为libcudart.a(-l指定)之类的库文件。

建议的解决方案:
(1)请确定你的cuda toolkit是安装到/usr/local下的。
(2)请确定你安装的cuda toolkit目录下的确存在libcudart.a/.so之类的文件,并且对当前用户是可读的。

欢迎楼主继续跟帖。
欢迎其他版主/会员继续为楼主的在linux环境下的配置支招。

(在回复此帖的时候风大回复了,建议无视此帖,然后去找找风大说的路径)

补充:我刚才问了一个用linux的某个版本的某种发行版的某cuda用户,他说他的toolkit默认安装到了/opt下,而不是/usr/local下,所以建议楼主仔细找找看是装到哪里去了。

对了,你可以这样搜索一下:
cd /然后回车
find -name libcuda.a然后回车
如果你机器上有libcuda.a存在,会列出。

这样你就可以知道正确的路径了。

祝楼主好运。

my install process

  1. sudo /etc/init.d/gdm stop

  2. Alt+F1 and then input “username”+“password” on main Keyboard

cd /home/tz/abc/driver/

sudo sh NVIDIA-Linux-x86-304.60.run

Accept blablabla… (gcc must be gcc-4.4,check it before step 1 and use gcc --version; sudo apt-get install gcc-4.4 g+±4.4)

finished installtion then input startx into x window

  1. install toolkit and SDK

sudo sh cuda_5.0.35_linux_32_ubuntu10.04.run

no more install for driver

choose Toolkit and SDK for yes

  1. sudo gedit ~/.bashrc

input this

export PATH=/usr/local/cuda-5.0/bin: $PATH
export LD_LIBRARY_PATH=/usr/local/cuda-5.0/lib: $LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib/nvidia-current: $LD_LIBRARY_PATH
export CUDA_ROOT=/usr/local/cuda-5.0/binlog out

  1. cd /home/tz/NVIDIA_CUDA-5.0_Samples/1_Utilities/deviceQuery/ make ./deviceQuery

tz@tz-dt:~/NVIDIA_CUDA-5.0_Samples/1_Utilities/deviceQuery$ ./deviceQuery
./deviceQuery Starting…

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: “GeForce GT 640”
CUDA Driver Version / Runtime Version 5.0 / 5.0
CUDA Capability Major/Minor version number: 3.0
Total amount of global memory: 2047 MBytes (2146762752 bytes)
( 2) Multiprocessors x (192 )CUDA Cores/MP: 384 CUDA Cores

I am sure toolkit 默认安装到了/opt下

善哉。根据你给出的文字,
果断去/usr/local/cuda-5.0/lib(或者lib64)下,和/usr/lib/nvidia-current下去找了。

你也可以看下风大的建议路径以及楼上。

lib64 for X64?
my Ubuntu is 32bit.
There is no cudart.so in /usr/local/cuda-5.0/lib

tz@tz-dt:/usr/local/cuda-5.0/lib$ ls
libcublas_device.a libcufft.so.5.0 libcusparse.so.5.0
libcublas.so libcufft.so.5.0.35 libcusparse.so.5.0.35
libcublas.so.5.0 libcuinj32.so libnpp.so
libcublas.so.5.0.35 libcuinj32.so.5.0 libnpp.so.5.0
libcudadevrt.a libcuinj32.so.5.0.35 libnpp.so.5.0.35
libcudart.so libcurand.so libnvToolsExt.so
libcudart.so.5.0 libcurand.so.5.0 libnvToolsExt.so.5.0
libcudart.so.5.0.35 libcurand.so.5.0.35 libnvToolsExt.so.5.0.35
libcufft.so libcusparse.so

but has a libcudart.so

那你需要修改makefile了。我看里面给出的是(/…/lib64)的路径。
也可能是你的makefile使用了环境变量里的某变量的值,而此值不对。

此外,关于楼主的10楼回帖的剩下部分,我建议你仔细重新阅读我的楼上的回帖:我让你找的就是带有lib前缀的。不要诬陷我。

如果你认为你能确定路径后,请考虑本帖的第一段文字。

lib64 must be for X64 Linux!

Just change “/usr/local/cuda/lib64” to “/usr/local/cuda-5.0/lib”

I have solved this problem. The code is running~!

Thanks to all the help!!

It is really helpfu! Thanks~!

嗯嗯。是的。你的理解正确。

恭喜楼主!

YES the path has been changed to /usr/local/cuda-5.0/lib .Thanks!!

With pleasure! Welcome to cudazone China.