【问题标题】:How to compile and link OpenCL using GCC with the NVIDIA Toolkit on Windows 7?如何在 Windows 7 上使用 GCC 和 NVIDIA 工具包编译和链接 OpenCL?
【发布时间】:2013-10-27 05:52:32
【问题描述】:

我在 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

这有什么问题吗?如何让它发挥作用?

【问题讨论】:

    标签: c windows gcc opencl


    【解决方案1】:

    在阅读了一些相关问题后,我安装了 mingw-utils,然后在 http://pastebin.com/f2ac38b2f 上使用 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 进行编译。现在它可以正常编译和工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-30
      • 2013-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多