我为我们当前需要OpenCL的Projekt设置我的PC(Win 7 Ultimate 64 CPU AMD / GPU AMD)时遇到了一个奇怪的问题。
我有MSYS所以我正在使用gcc进行mingw。我拼命想要编写一个名为openclexample的简单工作。
注意:包含“openclexample”的目录包含一个lib文件夹,其中包括重新实现的libOpenCL.a,OpenCL.lib和OVDecode64.lib。
Windows / system32中的OpenCL.dll
现在当我尝试使用
编译时$ gcc -std=c99 -lOpenCL -o openclexample.exe openclexample.c
我得到的是OpenCL.def中所有funktions侦听中的一堆未定义的引用错误
Ani@ANYONE /d/StuPro/OpenCLtests
$ gcc -std=c99 -lOpenCL -o openclexample.exe openclexample.c
openclexample.c: In function 'main':
openclexample.c:214:3: warning: implicit declaration of function 'srandom' [-Wim
plicit-function-declaration]
openclexample.c:217:7: warning: implicit declaration of function 'random' [-Wimp
licit-function-declaration]
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x35): undefin
ed reference to `clGetDeviceIDs@24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x8c): undefin
ed reference to `clCreateContext@24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0xd9): undefin
ed reference to `clCreateCommandQueue@20'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x127): undefi
ned reference to `clCreateProgramWithSource@20'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x17f): undefi
ned reference to `clBuildProgram@24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x1be): undefi
ned reference to `clCreateKernel@12'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x22c): undefi
ned reference to `clCreateBuffer@24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x264): undefi
ned reference to `clCreateBuffer@24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x29c): undefi
ned reference to `clCreateBuffer@24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x2f1): undefi
ned reference to `clSetKernelArg@16'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x319): undefi
ned reference to `clSetKernelArg@16'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x346): undefi
ned reference to `clSetKernelArg@16'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x373): undefi
ned reference to `clSetKernelArg@16'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x3e5): undefi
ned reference to `clEnqueueWriteBuffer@36'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x433): undefi
ned reference to `clEnqueueWriteBuffer@36'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x4b2): undefi
ned reference to `clEnqueueNDRangeKernel@36'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x51f): undefi
ned reference to `clEnqueueReadBuffer@36'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x54f): undefi
ned reference to `clFinish@4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x55d): undefi
ned reference to `clReleaseMemObject@4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x56b): undefi
ned reference to `clReleaseMemObject@4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x579): undefi
ned reference to `clReleaseMemObject@4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x587): undefi
ned reference to `clReleaseKernel@4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x595): undefi
ned reference to `clReleaseProgram@4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x5a3): undefi
ned reference to `clReleaseCommandQueue@4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x5b1): undefi
ned reference to `clReleaseContext@4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x72a): undefi
ned reference to `srandom'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x75f): undefi
ned reference to `random'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x7a4): undefi
ned reference to `random'
collect2: ld returned 1 exit status
我已经阅读了数百个线程,但没有找到解决方案,有些建议将其与-static链接,或者输入您的lib文件所在的路径......也不起作用。
如果有其他人有想法我真的很感激!
答案 0 :(得分:13)
链接器的参数必须按正确的顺序排列。您可以看到库搜索路径(-L)是正常的,因为链接器不会抱怨没有找到库。这些符号是未定义的,因为在使用它的对象/源文件之前提到了-lOpenCL。
$ gcc -std=c99 -o openclexample.exe openclexample.c -lOpenCL