0

我在 E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\ 安装了 NVIDIA GPU 计算工具包,我尝试使用以下命令编译 opencl 示例程序:

gcc hello.c -I "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include" -L "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\lib\Win32" -lOpenCL -o hello.exe

我有链接器错误:

E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x142):hello.c: undefined re
ference to `clGetPlatformIDs@12'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x179):hello.c: undefined re
ference to `clGetDeviceIDs@24'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x1b1):hello.c: undefined re
ference to `clCreateContext@24'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x1e0):hello.c: undefined re
ference to `clCreateCommandQueue@20'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x218):hello.c: undefined re
ference to `clCreateBuffer@24'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x24c):hello.c: undefined re
ference to `clCreateProgramWithSource@20'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x284):hello.c: undefined re
ference to `clBuildProgram@24'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x2a4):hello.c: undefined re
ference to `clCreateKernel@12'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x2cc):hello.c: undefined re
ference to `clSetKernelArg@16'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x2fc):hello.c: undefined re
ference to `clEnqueueTask@20'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x34e):hello.c: undefined re
ference to `clEnqueueReadBuffer@36'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x36d):hello.c: undefined re
ference to `clFlush@4'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x37e):hello.c: undefined re
ference to `clFinish@4'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x38f):hello.c: undefined re
ference to `clReleaseKernel@4'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x3a0):hello.c: undefined re
ference to `clReleaseProgram@4'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x3b1):hello.c: undefined re
ference to `clReleaseMemObject@4'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x3c2):hello.c: undefined re
ference to `clReleaseCommandQueue@4'
E:\Users\Lammar\AppData\Local\Temp/cc0Kbaaa.o(.text+0x3d3):hello.c: undefined re
ference to `clReleaseContext@4'
collect2: ld returned 1 exit status

它出什么问题了?如何让它工作?

4

1 回答 1

1

在阅读了一些相关问题后,我安装了 mingw-utils,然后dlltool -l libOpenCL.a -d OpenCL.def -A -khttp://pastebin.com/f2ac38b2f上使用并编译它:gcc hello.c -I "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include" -lOpenCL -o hello.exe。现在它编译并正常工作。

于 2013-10-27T06:54:19.543 回答