如何在MinGW中使用GLEW

itu*_*tun 8 c c++ opengl glew mingw

我试图在我的项目中使用glew32.lib文件链接,而不是自己编译Glew源来获取glew.a文件.现在,我的项目中存在以下链接错误:

g++ -o Chapter10(OpenCLTest).exe src\Chapter10(OpenCLTest).o -lopengl32 -lglew -lglut32 -lglu32 -lopencl
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x167): undefined reference to `_imp____glewBindBuffer'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x39a): undefined reference to `_imp__glewInit'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x3a7): undefined reference to `_imp__glewIsSupported'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x48a): undefined reference to `_imp____glewGenBuffers'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x495): undefined reference to `_imp____glewBindBuffer'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x4dd): undefined reference to `_imp____glewBufferData'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x50b): undefined reference to `_imp____glewGetBufferParameteriv'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x1d67): undefined reference to `_imp____glewBindBuffer'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x1d7f): undefined reference to `_imp____glewDeleteBuffers'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x1d95): undefined reference to `_imp____glewBindBuffer'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x1dad): undefined reference to `_imp____glewDeleteBuffers'
src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x2078): undefined reference to `_imp____glewBindBuffer'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

解决这个问题很好,但是按照我想问的方式,是否有任何其他opengl实现的gl extenten?

the*_*ine 5

我担心你不能在g ++中使用glew.lib(因为.lib是一种专有的Microsoft格式).您得到的这些错误缺少函数入口点,这意味着您没有正确编译GLEW(所需的函数不会导出到您的.so中 - 需要了解更多详细信息才能解决此问题).

至于问题的其他部分,你可以试试GLEH.它仍然处于开发阶段,可能需要一些调整才能为您工作,但我们已经在linux中使用它非常成功,所以它不应该太糟糕.


Tho*_*mas 1

您可以尝试GLee,它本质上与 GLEW 做同样的事情。