"Undefined reference to cutCreateTimer" on Linux

I get some errors while linking a small CUDA program that uses CUDA timer fucntions.
I’m using Fedora core 7 + Geforce 8800GTX with 100.14.11 series CUDA drivers. I’m able to run other CUDA programs that dont have timer functions.

Also, I’m able to compile and run “BandWidthTest” program in the CUDA_SDK.

tmpxft_00000bf8_00000000-8.i:(.text+0x6d53): undefined reference to cutCreateTimer' tmpxft_00000bf8_00000000-8.i:(.text+0x6d5e): undefined reference to cutStartTimer’
tmpxft_00000bf8_00000000-8.i:(.text+0x6d9d): undefined reference to cutStopTimer' tmpxft_00000bf8_00000000-8.i:(.text+0x6da8): undefined reference to cutGetTimerValue’
tmpxft_00000bf8_00000000-8.i:(.text+0x6df2): undefined reference to `cutDeleteTimer’
collect2: ld returned 1 exit status

Below is my Makefile:-

GCC_COMPILER = g++
GCC_COMPILER_FLAGS = -g -Wall

CUDA_COMPILER = nvcc
CUDA_COMPILER_FLAGS =

CUDA_INC_DIR = /usr/local/cuda/include
CUDA_LIB_DIR = /usr/local/cuda/lib
CUDA_SDK_INC_DIR = /usr/local/cuda_sdk/common/inc
CUDA_SDK_LIB_DIR = /usr/local/cuda_sdk/lib

CUDA_LIBS = -lcuda -lcudart
CUDA_SDK_LIBS = -lcutil
MISC_LIBS = -lm -lrt

INCS = -I$(CUDA_INC_DIR) -I$(CUDA_SDK_INC_DIR)
LIBS = -L$(CUDA_LIB_DIR) -L$(CUDA_SDK_LIB_DIR) (CUDA_LIBS) (CUDA_SDK_LIBS) $(MISC_LIBS)

TARGET = CpuToGpu

SRC_DIRS := .
SRC_FILES := (foreach DIR, (SRC_DIRS), (wildcard (DIR)/*.cpp))
OBJS := (patsubst %.cpp, %.o, (SRC_FILES))

CUDA_SRC_DIRS := .
CUDA_SRC_FILES := (foreach DIR, (CUDA_SRC_DIRS), (wildcard (DIR)/*.cu))
CUDA_OBJS := (patsubst %.cu, %.o, (CUDA_SRC_FILES))

all : $(TARGET)
echo All done

(TARGET) : (OBJS) (CUDA_OBJS) (GCC_COMPILER) (GCC_COMPILER_FLAGS) -o @ (LIBS) ^

%.o : %.cpp
(GCC_COMPILER) (GCC_COMPILER_FLAGS) -o @ -c (INCS) $<

%.o : %.cu
(CUDA_COMPILER) (CUDA_COMPILER_FLAGS) -o @ -c (INCS) $<

clean :
rm -f (OBJS) (CUDA_OBJS) $(TARGET)
echo Clean done

Have you compiled the cutil library?
Check if you have a file /usr/local/cuda_sdk/lib/libcutil.a. If not, run make from the /usr/local/cuda_sdk

Yes, I have compiled the cutil library and I have libcutil.a in /usr/local/cuda_sdk/lib

When I say -lcutil will it look for “libcutil.a” or “libcutil.so” ?

Look at the name of symbols in the .o and in the library:
nm *.o| grep cutCreateTimer
and
nm libcutil.a |grep cutCreateTimer

You may need to define them as external C

This is what worked for me:
ar -x libcutil.a
gcc -shared *.cpp_o -o libcutil.so -lGl -lGLU

I created a shared library from the static library since my makefile was looking for a shared library libcutil.so and not for the static library libcutil.a