Linker OpenCL未定义引用,但lib文件位于正确位置

Linker OpenCL未定义引用,但lib文件位于正确位置,linker,mingw,undefined,opencl,linker-errors,Linker,Mingw,Undefined,Opencl,Linker Errors,我在为当前需要OpenCL的项目设置我的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 现在,当我尝试使用 $ g

我在为当前需要OpenCL的项目设置我的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中列出的所有函数中的一堆未定义的引用错误

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文件所在的路径。。。也不管用


如果有人有主意,我会非常感激的

链接器的参数必须顺序正确。您可以看到库搜索路径(-L)是正常的,因为链接器不会抱怨找不到库。符号未定义,因为在使用它的对象/源文件之前提到了-lOpenCL

$ gcc -std=c99 -o openclexample.exe openclexample.c -lOpenCL