错误未定义对`cutCreateTimer'的引用

时间:2013-11-25 07:08:46

标签: cuda makefile

我在我的Ubuntu 12.04服务器上安装了cuda 4.0工具包。当我试图在Rodinia基准套件中构建一个cuda代码时。我收到以下错误。即,在运行make命令后

ncclab@slave13:~/Downloads/rodinia_2.4$ make
cd cuda/cfd;            make;   cp euler3d euler3d_double pre_euler3d pre_euler3d_double /home/ncclab/Downloads/rodinia_2.4/bin/linux/cuda  
make[1]: Entering directory `/home/ncclab/Downloads/rodinia_2.4/cuda/cfd'
nvcc  -O2 -Xptxas -v --gpu-architecture=compute_20 --gpu-code=compute_20 euler3d.cu -o euler3d -I/if10/kw5na/NVIDIA_GPU_Computing_SDK4/C/common/inc  -L/if10/kw5na/NVIDIA_GPU_Computing_SDK4/C/lib 
euler3d.cu:35: warning: #warning "the kernels may fail too launch on some systems if the block length is too large"
euler3d.cu:35: warning: #warning "the kernels may fail too launch on some systems if the block length is too large"

在这里建立了euler3d

nvcc -Xptxas -v -O3 --gpu-architecture=compute_20 --gpu-code=compute_20 euler3d_double.cu -o euler3d_double -I/if10/kw5na/NVIDIA_GPU_Computing_SDK4/C/common/inc  -L/if10/kw5na/NVIDIA_GPU_Computing_SDK4/C/lib 
/tmp/tmpxft_0000532d_00000000-12_euler3d_double.o: In function `main':
tmpxft_0000532d_00000000-1_euler3d_double.cudafe1.cpp:(.text+0x22d9): undefined reference to `cutCreateTimer'
tmpxft_0000532d_00000000-1_euler3d_double.cudafe1.cpp:(.text+0x22f7): undefined reference to `cutStartTimer'
tmpxft_0000532d_00000000-1_euler3d_double.cudafe1.cpp:(.text+0x2457): undefined reference to `cutStopTimer'
tmpxft_0000532d_00000000-1_euler3d_double.cudafe1.cpp:(.text+0x246c): undefined reference to `cutGetAverageTimerValue'

collect2: ld returned 1 exit status
make[1]: *** [euler3d_double] Error 1
make[1]: Leaving directory `/home/ncclab/Downloads/rodinia_2.4/cuda/cfd'
cp: cannot stat `euler3d_double': No such file or directory
cp: cannot stat `pre_euler3d': No such file or directory
cp: cannot stat `pre_euler3d_double': No such file or directory
make: *** [CUDA] Error 1

通过搜索,我发现libcutil可能存在问题 但我在〜/ NVIDIA_GPU_Computing_SDK / C / lib中有了libcutil_x86_64.a

编辑:各种文件夹的内容是 ncclab @ slave13:〜/ NVIDIA_GPU_Computing_SDK / C / lib $ ls

libcutil_x86_64.a  libparamgl_x86_64.a  librendercheckgl_x86_64.a

〜/ Downloads / rodinia_2.4 / cuda / cfd $ ls

euler3d     euler3d_double.cu  Makefile~        pre_euler3d.cu         README
euler3d.cu  Makefile           Makefile_nvidia  pre_euler3d_double.cu  run

ncclab @ slave13:〜/ NVIDIA_GPU_Computing_SDK / C / common / inc $ ls

bank_checker.h              cutil_inline.h          GL                nvVector.h           stopwatch_base.h
cmd_arg_reader.h            cutil_inline_runtime.h  multithreading.h  nvWidgets.h          stopwatch_base.inl
cuda_drvapi_dynlink.c       cutil_math.h            nvGlutWidgets.h   paramgl.h            stopwatch.h
cutil_gl_error.h            dynlink                 nvGLWidgets.h     param.h              stopwatch_linux.h
cutil_gl_inline.h           dynlink_d3d10.h         nvMath.h          rendercheck_d3d10.h
cutil.h                     dynlink_d3d11.h         nvMatrix.h        rendercheck_d3d11.h
cutil_inline_bankchecker.h  error_checker.h         nvQuaternion.h    rendercheck_d3d9.h
cutil_inline_drvapi.h       exception.h             nvShaderUtils.h   rendercheck_gl.h

makefile的部分内容是

all: euler3d euler3d_double pre_euler3d pre_euler3d_double

euler3d: euler3d.cu
    nvcc  -O2 -Xptxas -v --gpu-architecture=compute_20 --gpu-code=compute_20 euler3d.cu -o euler3d -I$(CUDA_SDK_PATH)/common/inc  -L$(CUDA_SDK_PATH)/lib $(CUTIL_LIB)

euler3d_double: euler3d_double.cu
    nvcc -Xptxas -v -O3 --gpu-architecture=compute_20 --gpu-code=compute_20 euler3d_double.cu -o euler3d_double -I$(CUDA_SDK_PATH)/common/inc  -L$(CUDA_SDK_PATH)/lib $(CUTIL_LIB)


pre_euler3d: pre_euler3d.cu
    nvcc -Xptxas -v -O3 --gpu-architecture=compute_20 --gpu-code=compute_20 pre_euler3d.cu -o pre_euler3d -I$(CUDA_SDK_PATH)/common/inc  -L$(CUDA_SDK_PATH)/lib $(CUTIL_LIB)

pre_euler3d_double: pre_euler3d_double.cu
    nvcc -Xptxas -v -O3 --gpu-architecture=compute_20 --gpu-code=compute_20 pre_euler3d_double.cu -o pre_euler3d_double -I$(CUDA_SDK_PATH)/common/inc  -L$(CUDA_SDK_PATH)/lib $(CUTIL_LIB)

euler3d已成功构建。所有剩余的三个文件都出现错误。所以我认为他们所指的目录中没有任何问题

我真的不明白为什么对`cutCreateTimer'和其他人的未定义引用正在发生。但是在SE中搜索我才知道当cutil.h或libcutil存在任何问题时,这些问题就会退出。我是linux环境的新手。所以请帮帮我

编辑2:在名为make.config的包含文件中,存在以下行

# CUDA SDK installation path
#SDK_DIR = $(HOME)/NVIDIA_GPU_Computing_SDK/C
SDK_DIR =/if10/kw5na/NVIDIA_GPU_Computing_SDK4/C
#SDK_DIR =/if10/kw5na/NVIDIA_CUDA_Computing_SDK4/C

默认情况下,选择第二个选项并构建euler3d。所以我认为可能因此存在问题。但改变它不会改变我面临的问题

关于make文件中存在的cutil库

CUDA_SDK_PATH := $(SDK_DIR)

# Determine the correct version of the cutil library
CUTIL_LIB = # -lcutil
ifeq ($(shell uname -m), x86_64)
    ifeq ($(shell if test -e $(SDK_DIR)/lib/libcutil_x86_64.a; then echo T; else echo F; fi), T)
        CUTIL_LIB = #-lcutil_x86_64
     endif
endif

我认为这是正确的

1 个答案:

答案 0 :(得分:2)

问题是你的编译命令是指定库路径,而不是提供cut...功能的库本身。

这显然是为nvcc生成euler3d_double编译命令的makefile行:

euler3d_double: euler3d_double.cu
    nvcc -Xptxas -v -O3 --gpu-architecture=compute_20 --gpu-code=compute_20 euler3d_double.cu -o euler3d_double -I$(CUDA_SDK_PATH)/common/inc  -L$(CUDA_SDK_PATH)/lib $(CUTIL_LIB)

这是生成的编译命令:

nvcc -Xptxas -v -O3 --gpu-architecture=compute_20 --gpu-code=compute_20 euler3d_double.cu -o euler3d_double -I/if10/kw5na/NVIDIA_GPU_Computing_SDK4/C/common/inc  -L/if10/kw5na/NVIDIA_GPU_Computing_SDK4/C/lib 

你会注意到makefile行中的最后两个标记是:

-L$(CUDA_SDK_PATH)/lib $(CUTIL_LIB)

-L$...令牌正在转换为正确的库路径。但$(CUTIL_LIB)令牌应该转换为-lcutil-lcutil_x86_64之类的内容,但这种情况不会发生。因此,缺少提供cut...Timer...函数的库,因此这些函数似乎未定义。

我会仔细检查Makefile以查看指定euler3d_double应该如何构建的行与之前的行之间是否存在任何行尾字符或其他不同之处指定应如何构建euler3d

您还应该能够通过查看为nvcc生成的euler3d编译命令行(您未显示)并将其与euler3d_double的命令行进行比较来确认这一点。 (失败了。)