Cannot compile cuda mex file ./nvmex: line 931: -c: command not found

Hello,

I recently installed CUDA and Matlab plugin on a Mac Pro but have trouble compiling. I recieve the following error when invoking the makefile:

$ make

./nvmex -f nvopts.sh knn.cu -I/usr/local/cuda/include -L/usr/local/cuda/lib

./nvmex: line 931: -c: command not found

I found another thread on this forum where this problem is solved by replacing "CC=nvcc’ with “CC=’/usr/local/cuda/bin/nvcc’” in nvopts.sh but it doesn’t work for me. Bandwithtest succesful and all that. The Makefile is pretty much the same except I added rule for mexmaci64 and altered Matlab installation folder. MEXEXT is properly returned (mexmaci64).

# 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)/lib # -Wl,-rpath,$(CUDAHOME)/lib

CFLAGS	  = -fPIC -D_GNU_SOURCE -pthread -fexceptions

COPTIMFLAGS = -O3 -funroll-loops -msse2

# Define installation location for MATLAB.

export MATLAB = /Applications/MATLAB_R2009b.app

MEX		   = $(MATLAB)/bin/mex

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 = knn.mex

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

clean:

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

.SUFFIXES: .cu .cu_o .mexglx .mexa64 .mexmaci64

.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.mexmaci64:

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

		$(INCLUDEDIR) $(INCLUDELIB)

.cu.mexmaci64:

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

line 931 is where the compilation command is executed. Any experience with this issue?

Looks like this problem was fixed for me by “chmod +x nvmex”; but now there is another one – I get the following error:
[indent]./nvmex -f nvopts.sh Szeta.cu -I/usr/local/cuda/include -L/usr/local/cuda/lib -lcufft -lcudart -Wl,-rpath,/usr/local/cuda/libversion
mex: /Applications/MATLAB_R2010a.app/extern/src/mexversion.c not a normal file or does not exist.
make: *** [Szeta.mexmaci] Error 1[/indent]

Oh btw – and also I think 64-bit mac is not supported; so one needs to (i) have a 32-bit Matlab compiler and (ii) export MACI64=0 to even get to the error message about mexversion.c :)