Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot find -lcuda when linking with g++

Tags:

c

gcc

g++

cuda

linker

I'm trying to link these object files with the command:

g++ NT_FFT_Decomp.o T_FFT_Decomp.o SNT_FFT_Comp.o ST_FFT_Comp.o VNT_FFT_Comp.o VT_FFT_Comp.o CUDA_FFT_Comp.o Globals.o main.o \
-L/media/wiso/Programs/Setups/CUDA/include -lcuda -lcudart -lpthread -o DevicesTest

/media/wiso/Programs/Setups/CUDA

is my cuda installation directory. and my LD_LIBRARY_PATH is like this :

Irrelevant:/media/wiso/Programs/Setups/CUDA/lib64:/media/wiso/Programs/Setups/CUDA/lib:Irrelevant

the command gives this error message:

/usr/bin/ld: cannot find -lcuda
/usr/bin/ld: cannot find -lcudart

removing -lcuda and -lcudart generates undefined reference to cuda functions errors.

how can I link this properly ??

like image 642
mewais Avatar asked May 13 '13 22:05

mewais


1 Answers

You need to add the compiler switch:

-L/usr/local/cuda/lib64

or something similar, to tell g++ where to find the -lcuda and -lcudart libraries.

In your case, the line is probably:

-L/media/wiso/Programs/Setups/CUDA/lib64

instead of the existing statement that you have. (change include to lib64 or possibly lib)

Again, LD_LIBRARY_PATH has nothing to do with compiling and linking.

like image 80
Robert Crovella Avatar answered Sep 24 '22 06:09

Robert Crovella