std::ifstream sourceFile(name);
std::string sourceCode(
std::istreambuf_iterator<char>(sourceFile),
(std::istreambuf_iterator<char>()));
Program::Sources source(1, std::make_pair(sourceCode.c_str(), sourceCode.length() + 1));
// Make program of the source code in the context
Program program = Program(context, source);
// Build program for these specific devices
errcode = program.build(devices);
And how to add path of my extern library?
I’m using AMD RX Vega 64
Based on OpenCL 1.2 specification (also the same for 2.0),
-I dir Add the directory dir to the list of directories to be searched for header files.
You cannot include any “.cl” into another “.cl”, but you can #include “Header.h” as much as you want where you can define some functions or define, etc.
Note that the code in those header must be in OpenCL C similar to your kernel (except if using OpenCL 2.2, where you can use OpenCL C++).
And lastly, except if you use OpenCL 2.0 and greater, you can’t call kernel function inside a kernel, so they must be ordinary function void foo().
So in your case, you could do this:
Program program = Program(context, source);
errcode = program.build(devices, "-I C:\Path\To\My\Include\Header);