Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Segmentation Fault for function resolved by QLibrary?
QtWS25 Last Chance

Segmentation Fault for function resolved by QLibrary?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 753 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CAD_codingC Offline
    CAD_codingC Offline
    CAD_coding
    wrote on last edited by
    #1

    I am loading OpenCL.dll at run time using QLibrary.

    @QLibrary *MyOpenCL::openCLLibrary = NULL;

    bool MyOpenCL::loadOpenCL()
    {
    if(openCLLibrary)
    return true;

    QLibrary *lib = new QLibrary("OpenCL");
    if(!lib->load())
        return false;
    
    bool result = false;
    typedef cl_int (*MyPlatorms)(cl_uint, cl_platform_id *, cl_uint *);
    MyPlatorms pobj = (MyPlatorms) lib->resolve("clGetPlatformIDs");
    if(pobj)
    {
        cl_uint nplatforms = 0;
        cl_uint myerr = pobj(INT_MAX, NULL, &nplatforms);
        if((myerr == CL_SUCCESS) && (nplatforms > 0))
        {
            cl_platform_id *mplatforms = new cl_platform_id[nplatforms];
            {
                const cl_uint csize = nplatforms;
                myerr = pobj(csize, mplatforms, &nplatforms);
            }
    
            typedef cl_int (*MyPlatformInfo)(cl_platform_id, cl_platform_info, size_t, void *, size_t *);
            MyPlatformInfo pinfoobj = (MyPlatformInfo) lib->resolve("clGetPlatformInfo");
            if(pinfoobj)
            {
                size_t size;
                for(unsigned int i = 0; i < nplatforms; i++)
                {
                    size = 0;
                    myerr = pinfoobj(mplatforms[i], CL_PLATFORM_VERSION, 0, NULL, &size);//line A
                    if(size < 1)
                        continue;
    
                    char *ver = new char[size];
                    {
                        const size_t csize = size;
                        myerr = pinfoobj(mplatforms[i], CL_PLATFORM_VERSION, csize, ver, &size);//line B
                    }
    

    ...
    }@

    When I am debugging at line B it jumps to line A and shows the Segmentation Fault error.
    I have spent 8 hours figuring this one out and so far I have had no luck.
    I am running Windows7 with MinGW compiler and my ATI 7670m has OpenCL 1.1 drivers.
    Please suggest me how to solve my problem?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved