5

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 ??

mewais
  • 1,265
  • 3
  • 25
  • 42

2 Answers2

7

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.

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
2

-L/media/wiso/Programs/Setups/CUDA/include // WRONG: "-L" is for libraries ... but "/include" is usually for headers

SUGGESTED CHANGE: -L/media/wiso/Programs/Setups/CUDA/lib64

COMPLETE LINK LINE:

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/lib64 -lcuda -lcudart -lpthread \
  -o DevicesTest
paulsm4
  • 114,292
  • 17
  • 138
  • 190