编译 OpenCL 文件时出现许多 LNK2019 错误

ora*_*les 1 c++ opencl

我一直在尝试OpenCLC++文件中使用。当我尝试编译它时,它给出了很多LNK2019错误,例如:

未解析的外部符号 _clGetPlatformIDs@12 在函数“public: static int __cdecl cl::Platform::get(class std::vector > *)”中引用 (?get@Platform@cl@@SAHPAV?$vector@VPlatform@cl@ @V?$allocator@VPlatform@cl@@@@std@@@std@@@Z)

Platform类中定义的cl.hpp,它使用clGetPlatformIds,在定义cl.h但没有付诸实施。我认为这就是问题所在。我怎样才能使代码工作?(我有 24 个未解析的外部符号)

Ari*_*nhh 5

LNK2019是 Microsoft Visual Studio 错误。将行添加#pragma comment(lib, "OpenCL.lib")到您的来源。您还应该在项目选项中指定库文件的路径:Project/ Properties/ Configuration Properties / VC++ Directories / Library Directories