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

Hi,

I’m using matlab 7.9.0 (R2009b) on linux 2.6.27.7-9 64 bit with a Tesla C1060 GPU card.

[font=“Courier New”]>> !nvcc --version

nvcc: NVIDIA ® Cuda compiler driver

Copyright © 2005-2009 NVIDIA Corporation

Built on Mon_Jul_13_12:35:34_PDT_2009

Cuda compilation tools, release 2.3, V0.2.1221[/font]

seems to work.

However, the fft CUDA example from Nvidia can not be compiled:

[font=“Courier New”]>> unix(‘make’)

/usr/local/matlab/bin/mex CFLAGS=‘-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=‘-O3 -funroll-loops -msse2’ fft2_cuda.c \

    -I/usr/local/cuda/include -L/usr/local/cuda/lib -lcufft -Wl,-rpath,/usr/local/cuda/lib

Warning: You are using gcc version “4.3.2”. 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 <a target='_blank' rel='noopener noreferrer' href='"http://gcc.gnu.org"'>http://gcc.gnu.org</a> 

/usr/lib64/gcc/x86_64-suse-linux/4.3/…/…/…/…/x86_64-suse-linux/bin/ld: cannot find -lcufft

collect2: ld returned 1 exit status

mex: link of ’ “fft2_cuda.mexa64”’ failed.

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

ans =

2[/font]

Does anybody have an idea why -lcufft can not be found?

Thanks a lot for help, OS

Change -L/usr/local/cuda/lib to -L/usr/local/cuda/lib64.
When the makefile was created, the toolkit had the 64bit libraries in lib, now ( CUDA 2.3 and later) they are in lib64

Thank for the hint:

I’ve changed the paths:

[codebox]# Define installation location for CUDA and compilation flags compatible

with the CUDA include files.

CUDAHOME = /usr/local/cuda

INCLUDEDIR = -I$(CUDAHOME)/include

INCLUDELIB = -L$(CUDAHOME)/lib64 -lcufft -Wl,-rpath,$(CUDAHOME)/lib64

CFLAGS = -fPIC -D_GNU_SOURCE -pthread -fexceptions

COPTIMFLAGS = -O3 -funroll-loops -msse2

Define installation location for MATLAB.

export MATLAB = /usr/local/matlab

#export MATLAB = /Applications/MATLAB_R2007b

MEX = $(MATLAB)/bin/glnxa64

MEXEXT = .$(shell $(MATLAB)/bin/mexext)

nvmex is a modified mex script that knows how to handle CUDA .cu files.

NVMEX = ./nvmex

List the mex files to be built. The .mex extension will be replaced with the

appropriate extension for this installation of MATLAB, e.g. .mexglx or

.mexa64.

MEXFILES = fft2_cuda.mexa64 \

       fft2_cuda_sp_dp.mexa64 \

       ifft2_cuda.mexa64      \

       Szeta.mexa64

all: $(MEXFILES:.mex=$(MEXEXT))

clean:

rm -f $(MEXFILES:.mex=$(MEXEXT))

.SUFFIXES: .cu .cu_o .mexglx .mexa64 .mexmaci

.c.mexglx:

$(MEX) CFLAGS='$(CFLAGS)' COPTIMFLAGS='$(COPTIMFLAGS)' $< \

    $(INCLUDEDIR) $(INCLUDELIB)

.cu.mexglx:

$(NVMEX) -f nvopts.sh $< $(INCLUDEDIR) $(INCLUDELIB)

.c.mexa64:

$(MEX) CFLAGS='$(CFLAGS)' COPTIMFLAGS='$(COPTIMFLAGS)' $< \

    $(INCLUDEDIR) $(INCLUDELIB)

.cu.mexa64:

$(NVMEX) -f nvopts.sh $< $(INCLUDEDIR) $(INCLUDELIB)

.c.mexmaci:

$(MEX) CFLAGS='$(CFLAGS)' COPTIMFLAGS='$(COPTIMFLAGS)' $< \

    $(INCLUDEDIR) $(INCLUDELIB)

.cu.mexmaci:

$(NVMEX) -f nvopts.sh $< $(INCLUDEDIR) $(INCLUDELIB)

[/codebox]

Then I end up with the follwing error message:

[codebox]>> unix(‘make’);

/usr/local/matlab/bin/glnxa64 CFLAGS=‘-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=‘-O3 -funroll-loops -msse2’ fft2_cuda.c \

    -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcufft -Wl,-rpath,/usr/local/cuda/lib64

make: execvp: /usr/local/matlab/bin/glnxa64: No authorization

make: *** [fft2_cuda.mexa64]

Error 127[/codebox]

The directory /usr/local/matlab/bin/glnxa64 exists and I’ve the rights to write and execute there.

When I change mex file extensions with glx:

[codebox]MEXFILES = fft2_cuda.mexglx \

       fft2_cuda_sp_dp.mexglx \

       ifft2_cuda.mexglx      \

       Szeta.mexglx[/codebox]

then I get the following:

[codebox]>> unix(‘make’);

/usr/local/matlab/bin/glnxa64 CFLAGS=‘-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=‘-O3 -funroll-loops -msse2’ fft2_cuda.c \

    -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcufft -Wl,-rpath,/usr/local/cuda/lib64

make: execvp: /usr/local/matlab/bin/glnxa64: No authorization

make: *** [fft2_cuda.mexglx]

Error 127[/codebox]

Does anybody has an idea what should be changed?

Thanks, OS