Matlab plug-in for CUDA makefile problems cannot make the plug-in

Hi everyone, I’m very new at this, so bear with me!

I installed CUDA, and am even able to write some C files with it. I am now trying to get CUDA to work in mex in matlab. I downloaded the plugin, but when I try to run the Makefile I always get:

/usr/local/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ fft2_cuda.c
-I/usr/local/cuda/include -I/home/fguichard/NVIDIA_CUDA_SDK/common/inc -L/usr/local/cuda/lib -lcufft -Wl,-rpath,/usr/local/cuda/lib

Warning: You are using gcc version “4.3.3-5ubuntu4)”. The earliest gcc version supported
with mex is “4.1”. The latest version tested for use with mex is “4.2”.
To download a different version of gcc, visit

fft2_cuda.o: In function mexFunction': fft2_cuda.c:(.text+0xe4f): undefined reference to cudaMalloc’
fft2_cuda.c:(.text+0xe64): undefined reference to cudaMemcpy' fft2_cuda.c:(.text+0xeac): undefined reference to cudaMemcpy’
fft2_cuda.c:(.text+0xf01): undefined reference to `cudaFree’
collect2: ld returned 1 exit status

mex: link of ' "fft2_cuda.mexa64"' failed.

make: *** [fft2_cuda.mexa64] Error 1

I think this is linked to the Makefile somehow, but I cannot figure out why. I cannot just include common/ as I do with regular C files.

Any help would be extremely appreciated! If someone who got this plug-in to work could describe their steps to me, I’d be very thankful.

Add -lcudart