2 Replies Latest reply on Mar 17, 2010 4:39 PM by griffin2000

    Anyone been able to dynamically link OpenCL

    griffin2000

      For our project we need to be able to dynamically link OpenCL (so our application can compiled and run on machines without OpenCL installed on them, and only use it if its there).

      I'm trying to dynamically load and run the DLL (I've tried this on Stream SDK 2.01 on windows Xp and Windows 7, using VS2008) using code like that shown below to dynamically link and run OpenCL.  But I get an ESP stack check execption like this one when I try and run the retreived function pointer:

      [quote]Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.[/quote]

       

      I've tried various combinations of calling convention to no avail.  Has anyone sucessfully done this ?  Is there a particular compile setting, pragma, service pack, or something else I need to do this ?

       

       

       

      #include "Windows.h" #include "CL/cl.h" typedef CL_API_ENTRY cl_int CL_API_ENTRY (*clGetPlatformIDsCBType) ( cl_uint num_entries, cl_platform_id * platforms, cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0; int main(int argc, char* argv[]) { cl_uint numPlatforms; HMODULE pOpenCLLib=LoadLibrary("OpenCL.dll"); clGetPlatformIDsCBType clGetPlatformIDsCB=(clGetPlatformIDsCBType) GetProcAddress(pOpenCLLib,"clGetPlatformIDs"); ( clGetPlatformIDsCB(0, NULL, &numPlatforms) ); return 0; }