OpenCL C/C++ dynamic binding library (win32 and mo

2019-05-10 09:51发布

问题:

I'm giving a try at OpenCL, and in order to put this in production I'd like to be able to bind dynamically to OpenCL.DLL (when under Windows), in order to handle 'gracefully' the case where no OpenCL is installed on the host computer.

Is there any available library (or code snippet) that takes care of this dynamic binding in C or C++, much like GLEW does for OpenGL ? I'd like to avoid the hassle to do it myself.

Thanks,

回答1:

Here you go:

http://clcc.sourceforge.net/clew_8h.html



回答2:

Since you're dealing with Win32, the easiest solution is delay loading. If you delay-load OpenCL, and the compiler-added stub fails to find it, it will call __pfnDliFailureHook2(dliFailLoadLib). You can handle the error there; if you don't provide a handler you'll get the default behavior (program aborts). In either case the program will not have a static dependency on OpenCL.



回答3:

QtOpenCL http://labs.qt.nokia.com/2010/04/07/using-opencl-with-qt/