wglGetCurrentDC未解析外部

时间:2016-08-08 02:50:55

标签: c++ qt opengl opencl

我想我已经因为这种问题而陷入雷霆之中。我正在使用visual studio 2015社区和qt5.6.0(msvc2015_64),以便制作一个QOpenglWidget来演示使用OpenCL设备计算的结果。

现在我使用函数“wglGetCurrentContext”和“wglGetCurrentDC”盲目创建上下文,错误是:

“LNK2019未解析的外部符号_imp_wglGetCurrentContext在函数中引用”protected:void _cdecl VolRenGL :: createCLContext(int,char const * )“(?createCLContext @ VolRenGL @ IEAAXHPEAPEBD @ Z)” “LNK2019未解析的外部符号_imp_wglGetCurrentDC在函数中引用”protected:void _cdecl VolRenGL :: createCLContext(int,char const *)“(?createCLContext @ VolRenGL @@ IEAAXHPEAPEBD @ Z)”

相关代码:

cl_context_properties props[] =
        {
            CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
            CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
            CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform,
            0
        };
        cxGPUContext = clCreateContext(props, 1, &cdDevices[uiDeviceUsed], NULL, NULL, &err);

1 个答案:

答案 0 :(得分:1)

愚蠢的问题,但您是否将您的计划与opengl32.lib/dll相关联?在Windows中,链接到DLL中的符号不​​会泄漏"因此您必须链接到正确的库。 Qt通过提供OpenGL加载器来隐藏这个问题,所以如果你编写一个完全惯用的Qt OpenGL程序,你可以这样做,而不实际明确链接opengl32.lib/dll

相关问题