Hello,
I am using Qt for developing my application and it has a class which loads libraries at run time.
For the following code I am getting a segmentation fault.
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 6 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?