如何使用GCC与Windows 7上的英伟达工具包编译和链接OpenCL? 英伟达GPU计算工具包安装在E:\程序文件\Nvidia GPU计算工具包\CUDA\V4.2\,我尝试编译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

如何使用GCC与Windows 7上的英伟达工具包编译和链接OpenCL? 英伟达GPU计算工具包安装在E:\程序文件\Nvidia GPU计算工具包\CUDA\V4.2\,我尝试编译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,c,windows,gcc,opencl,C,Windows,Gcc,Opencl,我有链接器错误: 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

我有链接器错误:

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

怎么了?如何让它工作?

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