Using libcutil.a and MEX Using cutil.h with cutCreateTimer MEX

Hello All,

While trying to use the Nvmex script. I can get most of my CUDA code compiled fine. However I think that for some reason the NVMEX script cannot see the libcutil.a which is located in the $SDK/lib/ Due to this I cannot use cutCreateTimer() and the associated timer functions.

This is only restricted to the createTimer functions and at run time when I get the message undefined symbol: cutCreateTimer.

I modified the make file to add a path to libcutil.a as seen below and the Makefile already has the fPIC switch present. I noticed that the libraries located in $CUDAHOME like libcufft and so on are in a form like *.so.1 and so on. Are they linked by a different method?

I get a error as below when I make the Makefile point at the libcutil file (as shown below)

usr/bin/ld: /home/pmistry/NVIDIA_CUDA_SDK/lib/libcutil.a(cutil.cpp_o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

/home/pmistry/NVIDIA_CUDA_SDK/lib/libcutil.a: could not read symbols: Bad value

I have also tried copying libcutil.a to the location where cufft and the other libraries are.

I have pasted the relevant part of the Makefile as well

# Define installation location for CUDA and compilation flags compatible

# with the CUDA include files.

CUDAHOME    = /usr/local/cuda


INCLUDELIB  = -L$(CUDAHOME)/lib -lcuda -lcufft -lcublas -lcudart -Wl,-rpath,$(CUDAHOME)/lib,/home/pmistry/NVIDIA_CUDA_SDK/lib/libcutil.a

CFLAGS      = -fPIC -D_GNU_SOURCE -pthread -fexceptions -Wall

COPTIMFLAGS = -O3 -funroll-loops -msse2

# Define installation location for MATLAB.

export MATLAB = /usr/local/matlab

#export MATLAB = /Applications/MATLAB_R2007b

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

I would appreciate it if some one tells me what to do to libcutil.a so that I can add cutil.h and get it to work with NVMex

Thank You

Hi All,

I also have the same problem. NVmex compilation of my .cu code gives the following error:

“fatal error C1083: Cannot open include file: ‘cutil.h’: No such file or directory”

Also, I cannot somehow use even error-handling (CUDA_SAFE_CALLs) with nvmex. I get an error “error: identifier “CUDA_SAFE_CALL” is undefined”.

I tried looking for different relevant forums but could not gather any clue. Will appreciate someone helping out with these issues.

Thanks & regards,


Hi ,

Any update on this problem ?


Try include