Many LNK2019 errors when compiling OpenCL file

4.3k Views Asked by At

I've been trying to use OpenCL in a C++ file. When I try to compile it, it gives a lot of LNK2019 errors, such as :

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)

The Platform class is defined in cl.hpp, and it uses clGetPlatformIds, defined in cl.h but not implemented. I think that is the problem. How can I make the code work ? (I have 24 unresolved external symbols)

1

There are 1 best solutions below

3
On BEST ANSWER

LNK2019 is a Microsoft Visual Studio error. Add line #pragma comment(lib, "OpenCL.lib") to your source. You also should specify path to the library file in the project options: Project/ Properties/ Configuration Properties / VC++ Directories / Library Directories