c++ - wglGetCurrentDC 未解析的外部

标签 c++ qt opengl opencl

我想我已经被这种问题逼疯了。我正在使用带有 qt5.6.0 (msvc2015_64) 的 visual studio 2015 社区来制作 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);

最佳答案

愚蠢的问题,但是您是否将您的 程序与opengl32.lib/dll 链接起来?在 Windows 中,链接到 DLL 的符号不会“泄漏”,因此您必须链接到正确的库。 Qt 通过还提供一个 OpenGL 加载器隐藏了这个问题,因此如果您编写一个完全惯用的 Qt OpenGL 程序,您可以这样做而无需实际显式链接到 opengl32.lib/dll

关于c++ - wglGetCurrentDC 未解析的外部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38820643/

相关文章:

c++ - Qt:如果你发送信号太快会发生什么?

opengl - 计算多维数据集的索引缓冲区大小

c++ - 鼠标单击一次注册两次 C++/GLUT

opengl - SPIR-V 字节码是否提供混淆?

c++ - MPI_Waitall 实际上是如何工作的

qt - QT和OpenCV错误:找不到core.hpp

qt - 如何更改 Tumbler 中所选项目的颜色

c++ - 调用 boolean 函数但出现错误 "no matching function to call"?

c++ - C++中的内存分配

c++ - 为什么 CMake COMPILER_DEFINITIONS 不传播到子目录?