编译 OpenCL 文件时LNK2019许多错误



我一直在尝试在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

最新更新