Way to know if OpenCL is installed


I got a problem. Imagine my app uses OpenCL but it requires to be compatible with old OSs and computers. The user might use an old driver without OpenCL suport.
Currently, if I link my program with the OpenCL.lib/OpenCL.dll then the dynamic-library reference will make my program impossible to be executed. It’s neither possible to use “delayed DLL” calls, because Windows will emit a “Sorry can’t find OpenCL.dll DLL” message box the first time you call a clXXXXXXX function.

To solve that, you should add an INLINED function in the OpenCL.h file to know if OpenCL is available. For instance, in case of Windows, it could be like this:

void inline int IsOpenCLInstalled ()
    #ifdef WIN32
       FILE *f = fopen("$WINDIR\\system32\\OpenCL.dll");
       if ( f!=NULL )
           return 1;
       return 0;
       /* perform OpenCL runtime detection for other OSs */


I would suggest dynamically opening the library with LoadLibrary()/dlopen() instead.

It would be handy to try to ask the available OpenCL context versions.
If it fails no library.
If it returns something useful you can immediately start working with that.