无法在动态 link 库中找到过程入口点 clCreateCommandQueueWithProperties

The procedure entry point clCreateCommandQueueWithProperties could not be located in the dynamic link library

我一直在尝试让 OpenCL 与 visual studio 一起工作。

我关注了this guide for configuring the AMD OpenCL SDK.

这是我的简短示例程序

#include "stdafx.h"
#include <CL/cl.h>
#include <stdio.h>
#include <iostream>

using namespace std;

const char *source =
"__kernel void memset( __global uint *dst ) \n"
"{ \n"
" dst[get_global_id(0)] = get_global_id(0); \n"
"} \n";

int main()
{
    cl_platform_id platform;

    clGetPlatformIDs(1, &platform, NULL);

    cl_device_id device;

    clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);

    cl_context context = clCreateContext
    (
        NULL,
        1,
        &device,
        NULL, 
        NULL, 
        NULL
    );


    cl_command_queue queue = clCreateCommandQueueWithProperties
    (
        context,
        device,
        0, 
        NULL
    );


    return 0;

} 

但是当我 运行 它时,我得到这个 运行 时间错误

The procedure entry point clCreateCommandQueueWithProperties could not be located in the dynamic link library

我使用 dll export viewer 查看了 dll,该函数确实出现在 OpenCL.dll.

编辑

我认为 Mats Petersson 是对的我在我的 PC 上进行了文件搜索并找到了多个 OpenCL.dll 个文件

我不确定如何以合理的方式解决此问题....

编辑

这里可能还值得注意的是,当我删除对 clCreateCommandQueueWithProperties 的调用时,程序 运行 运行良好。

我的一些朋友建议将 OpenCL.DLL 文件复制到我的项目目录中。

效果很好。

我的程序一定是加载了错误的 dll 文件。

我用 C:\Program Files (x86)\AMD APP SDK.0\bin\x86\OpenCL.dll

替换了 C:\Windows\System32\OpenCL.dll

我用 C:\Program Files (x86)\AMD APP SDK.0\bin\x86_64\OpenCL.dll

替换了 C:\Windows\SysWOW64\OpenCL.dll

这对我有用。

我在尝试 运行 QGIS 时遇到了这个错误。

在 OSGeo4W 中重新安装 OpenCL 解决了问题。