使用SDL 2和GLEW 2.0编译c ++项目时链接错误

时间:2016-09-16 20:40:55

标签: c++ opengl g++ sdl glew

我正在使用SDL 2和GLEW 2.0开始一个c ++项目,我想在命令行中使用g ++进行编译(我试图避免像Visual Studio或Code :: Block这样的IDE)。我能够在GameEngine类中创建一个基本的opengl三角形,但是一旦我添加了Sprite类,我就会收到以下错误:

g++ ./src/main.cpp ./src/gameEngine/GameEngine.cpp ./src/gameEngine/Sprite.cpp ./src/gameEngine/Sprite.h ./src/gameEngine/GameEngine.h -I./lib/SDL2_32/include -I./lib/GLEW2_32/include -L./lib/SDL2_32/lib -L./lib/GLEW2_32/lib -w  -std=gnu++11 -lmingw32 -lSDL2main -lSDL2 -lOpenGL32 -lglew32 -o ./bin/main
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x2a): undefined reference to `__glewDeleteBuffers'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x7f): undefined reference to `__glewGenBuffers'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x125): undefined reference to `__glewBindBuffer'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x141): undefined reference to `__glewBufferData'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x16a): undefined reference to `__glewBindBuffer'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x193): undefined reference to `__glewBindBuffer'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x1ae): undefined reference to `__glewEnableVertexAttribArray'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x1bf): undefined reference to `__glewVertexAttribPointer'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x217): undefined reference to `__glewDisableVertexAttribArray'
C:\Users\DANIEL~1\AppData\Local\Temp\ccn1bkfX.o:Sprite.cpp:(.text+0x228): undefined reference to `__glewBindBuffer'
collect2.exe: error: ld returned 1 exit status
Makefile:36: recipe for target 'all' failed
make: *** [all] Error 1

似乎存在链接错误,因此Sprite无法访问glew的定义。我尝试了在线发布的每一个解决方案,但大多数都关注Microsoft visual studio或Code :: Block而不是命令行..请帮忙!

0 个答案:

没有答案