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

标签 c++ opencl

<分区>

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

unresolved external symbol _clGetPlatformIDs@12 referenced in function "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个未解析的外部符号)

最佳答案

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

关于c++ - 编译 OpenCL 文件时出现许多 LNK2019 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30888491/

相关文章:

c++ - 我的 cocos2d 游戏启动,比其他音乐应用程序停止

c++ - 表达式的数学定义结果

c++ - clGetDeviceInfo 和 clGetPlatformInfo 在 OpenCL 中失败,错误代码为 -30 (CL_INVALID_VALUE)

opencl - 如何将 "stream"数据传入和传到全局内存?

crash - OpenCL-内核在第二次运行时崩溃

event-handling - 教程 OpenCl 事件处理

python - 使用 CUDA 或 OpenCL 在 python 中进行多维 FFT

c++ - 什么决定从 std::endl 输出哪些字节

c++ - 从 blitz 数组中获取存储类型

c++ - CL_INVALID_KERNEL_NAME : when Struct in Kernel (Opencl)