Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4583520
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:13:34+00:00 2026-05-21T21:13:34+00:00

I’m currently trying to edit a project, that already uses OpenCL.dll, to make it

  • 0

I’m currently trying to edit a project, that already uses OpenCL.dll, to make it load the library dynamically. I want to be able to use it in no OpenCL systems, with only a error mesage and a feature disabled.

First, I added some wrappers to the functions. (This code in inside a C++ class, and is public)

    typedef cl_int h_clGetPlatformIDs(cl_uint, cl_platform_id *, cl_uint *);
    typedef cl_int h_clGetDeviceIDs(cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
    typedef cl_context h_clCreateContext(cl_context_properties *, cl_uint, const cl_device_id *, void *(const char *, const void *, size_t, void *), void *, cl_int *);
    typedef cl_command_queue h_clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int *);
    typedef cl_program h_clCreateProgramWithSource(cl_context, cl_uint, const char **, const size_t *, cl_int *);
    typedef cl_int (CALLBACK h_clBuildProgram)(cl_program, cl_uint,const cl_device_id *, const char *, void (*)(cl_program, void * ), void * ) CL_API_SUFFIX__VERSION_1_0;
    typedef cl_int h_clGetProgramBuildInfo(cl_program, cl_device_id, cl_program_build_info, size_t, void  *, size_t  *);
    typedef cl_kernel h_clCreateKernel(cl_program, const char *, cl_int *);
    typedef cl_mem h_clCreateBuffer(cl_context, cl_mem_flags, size_t, void *, cl_int *);
    typedef cl_int h_clEnqueueWriteBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
    typedef cl_int h_clSetKernelArg(cl_kernel, cl_uint, size_t, const void *);
    typedef cl_int h_clEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*);
    typedef cl_int h_clFlush(cl_command_queue);
    typedef cl_int h_clEnqueueReadBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *);
    typedef cl_int h_clWaitForEvents(cl_uint, const cl_event *);
    typedef cl_int h_clReleaseMemObject(cl_mem );
    typedef cl_int h_clReleaseEvent(cl_event );
    typedef cl_int h_clReleaseProgram(cl_program );
    typedef cl_int h_clReleaseKernel(cl_kernel);
    typedef cl_int h_clReleaseCommandQueue(cl_command_queue );
    typedef cl_int h_clReleaseContext(cl_context );

    h_clGetPlatformIDs* clGetPlatformIDs;
    h_clGetDeviceIDs* clGetDeviceIDs;
    h_clCreateContext* clCreateContext;
    h_clCreateCommandQueue* clCreateCommandQueue;
    h_clCreateProgramWithSource* clCreateProgramWithSource;
    h_clBuildProgram* clBuildProgram;
    h_clGetProgramBuildInfo* clGetProgramBuildInfo;
    h_clCreateKernel* clCreateKernel;
    h_clCreateBuffer* clCreateBuffer;
    h_clEnqueueWriteBuffer* clEnqueueWriteBuffer;
    h_clSetKernelArg* clSetKernelArg;
    h_clEnqueueNDRangeKernel* clEnqueueNDRangeKernel;
    h_clFlush* clFlush;
    h_clEnqueueReadBuffer* clEnqueueReadBuffer;
    h_clWaitForEvents* clWaitForEvents;
    h_clReleaseMemObject* clReleaseMemObject;
    h_clReleaseEvent* clReleaseEvent;
    h_clReleaseProgram* clReleaseProgram;
    h_clReleaseKernel* clReleaseKernel;
    h_clReleaseCommandQueue* clReleaseCommandQueue;
    h_clReleaseContext* clReleaseContext;

With that, I’m able to directly assign the handlers what GetProcAdress returns, and after that just call the function (of course, I load the DLL first).

    clReleaseContext = (h_clReleaseContext*) GetProcAddress(ocl_lib_handle, "clReleaseContext");

And a common call example:

clReleaseContext((cl_context)context);

But I always get SEGFAULT calling this one:

clBuildProgram(program, 0, NULL, "-cl-fast-relaxed-math", NULL, NULL);

It’s strange, since all the other ones work OK.
I post here the clBuildProgram Args as reference:

    extern CL_API_ENTRY cl_int CL_API_CALL
clBuildProgram(cl_program           /* program */,
               cl_uint              /* num_devices */,
               const cl_device_id * /* device_list */,
               const char *         /* options */, 
               void (*pfn_notify)(cl_program /* program */, void * /* user_data */),
               void *               /* user_data */) CL_API_SUFFIX__VERSION_1_0;

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:13:35+00:00Added an answer on May 21, 2026 at 9:13 pm

    Your typedefs have to match the declaration in the OpenCL headers exactly. They don’t, you don’t use CL_API_ENTRY, CL_API_CALL. I don’t see CALLBACK in the original declaration for the 1st argument.

    This is of course horrible code to write and maintain. The clBuildProgram() function has otherwise plenty of opportunities to bomb on an access violation without you helping. Smoke this out first with a test program that gets your main code running properly. Beg, steal or borrow to take advantage of the MSVC linker’s /DELAYLOAD feature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.