geometrian
geometrian

Reputation: 15387

Linking Error for clCreateFromGLTexture Only

I am trying to allow OpenCL to render to 2D textures. I first encountered the function clCreateFromGLTexture2D. I wrote it in, but when I went to compile, I found that it was not defined. I eventually found it in "cl_gl.h":

#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
#warning CL_USE_DEPRECATED_OPENCL_1_1_APIS is defined. These APIs are unsupported and untested in OpenCL 1.2!
    extern CL_API_ENTRY cl_mem CL_API_CALL
    clCreateFromGLTexture2D(cl_context      /* context */,
                            cl_mem_flags    /* flags */,
                            cl_GLenum       /* target */,
                            cl_GLint        /* miplevel */,
                            cl_GLuint       /* texture */,
                            cl_int *        /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;

    extern CL_API_ENTRY cl_mem CL_API_CALL
    clCreateFromGLTexture3D(cl_context      /* context */,
                            cl_mem_flags    /* flags */,
                            cl_GLenum       /* target */,
                            cl_GLint        /* miplevel */,
                            cl_GLuint       /* texture */,
                            cl_int *        /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
#endif /* CL_USE_DEPRECATED_OPENCL_1_2_APIS */

So, I looked elsewhere in "cl_gl.h" and I found clCreateFromGLTexture. In the interest of forward compatibility, I wrote that into the code instead. However, the function clCreateFromGLTexture causes a LNK2019 (unresolved external). I find this very suspect, as I CAN compile when using clCreateFromGLBuffer and clCreateFromGLRenderbuffer, and both of these are ALSO in "cl_gl.h".

So, my question: why doesn't clCreateFromGLTexture have a definition, while the functions right next to it in the same module do? I am currently linking against "OpenCL.lib". Is there anything else I need? I didn't see anything. Is this a problem with the library itself?

[EDIT: clGetDeviceInfo(device_id,CL_DEVICE_IMAGE_SUPPORT,sizeof(cl_bool),&result,NULL); is CL_TRUE, for what it's worth.]

Thanks,

Upvotes: 0

Views: 1219

Answers (2)

Nike
Nike

Reputation: 475

Even I got this error and I had some tough time fixing it. I guess you are using VS2010. This may happen for reasons such as:

  1. you have not included the reference to the library in the project properties -> linker -> input -> Additional Library dependencies

  2. you have compiled the solution as 32bit and using the 64bit library file or vice versa.

Check it out.

Upvotes: 0

panickal
panickal

Reputation: 1164

Try updating the OpenCL libraries to the latest version(1.2).

clCreateFromGLTexture is defined as part of the OpenCL 1.2 standard, whereas clCreateFromGLTexture2D and clCreateFromGLTexture3D are part of OpenCL 1.0. If your OpenCL library is not up to date, you will get an undefined error.

Upvotes: 3

Related Questions