gpt4 book ai didi

c - 如何在 Windows 7 上使用 GCC 和 NVIDIA Toolkit 编译和链接 OpenCL?

转载 作者:行者123 更新时间:2023-11-30 15:44:10 24 4
gpt4 key购买 nike

我在E:\Program Files\NVIDIA GPUComputing 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

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

最佳答案

阅读了一些相关问题后,我安装了 mingw-utils,然后在 http://pastebin.com/f2ac38b2f 上使用 dlltool -l libOpenCL.a -d OpenCL.def -A -k并使用以下命令进行编译:gcc hello.c -I "E:\Program Files\NVIDIA GPU Compute Toolkit\CUDA\v4.2\include"-lOpenCL -o hello.exe。现在可以正常编译并运行了。

关于c - 如何在 Windows 7 上使用 GCC 和 NVIDIA Toolkit 编译和链接 OpenCL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19615097/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com