我一直在尝试在C++
文件中使用OpenCL
。当我尝试编译它时,它给出了很多LNK2019错误,例如:
函数中引用的未解析外部符号_clGetPlatformIDs@12 "public: static int __cdecl cl::P latform::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 个未解析的外部符号)
LNK2019
是Visual Studio Microsoft错误。将行#pragma comment(lib, "OpenCL.lib")
添加到源。您还应该在项目选项中指定库文件的路径:Project/ Properties/ Configuration Properties / VC++ Directories / Library Directories