在过去的 24 个工作小时里,我尝试使用多个搜索和教程来编译它(有人说我需要动态链接它,而另一些人说我需要静态链接),我无法让它工作。我对编译和链接比较陌生,因此将不胜感激。
这是我的代码(从我的评论可以看出,我昨晚写代码很累):
#define NO_SDL_GLEXT
#define GLEW_STATIC
#include "GL/glew.h"
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"
int main (int argc, char* args[]){
//Loads the SDL video module
SDL_Init(SDL_INIT_VIDEO);
//Creates the SDL Surface for OpenGL to draw to
SDL_Surface* surface = SDL_SetVideoMode(800,600,32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_OPENGL );
//Sets the caption...
SDL_WM_SetCaption("OpenGL",0);
glewExperimental = GL_TRUE;
glewInit();
//Main event loop, this is the BREAD AND BUTTER LADIES AND GENTLEMEN
SDL_Event windowEvent;
while (true){
if (SDL_PollEvent(&windowEvent)){
//If you close the appplication, causes it to actually stop running :D
if (windowEvent.type == SDL_QUIT) break;
//Close it with the ESC key! :D:D:D:D:D:D:D:D:D:
if (windowEvent.type == SDL_KEYUP && windowEvent.key.keysym.sym == SDLK_ESCAPE) break;
}
//Literally the one extra line of code needed to do double buffering
SDL_GL_SwapBuffers();
}
//I wish I knew what this ended...LOPE JK
SDL_Quit();
return 0;
}
在我的搜索目录中:
编译器:
E:\Programs\CodeBlocks\glew-1.10.0\include
E:\Programs\CodeBlocks\SDL-1.2.15\include
链接器:
E:\Programs\CodeBlocks\glew-1.10.0\lib\Release\x64
E:\Programs\CodeBlocks\SDL-1.2.15\lib
最后在我的链接器设置中
链接库:
E:\Programs\CodeBlocks\glew-1.10.0\lib\Release\x64\glew32s.lib
其他链接器选项:
-lmingw32 -lglew32s -DGLEW_STATIC -lSDLmain -lSDL
我目前得到的错误是:
In function 'SDL_main':
undefined reference to `glewExperimental'
undefined reference to `glewInit@0'
预先感谢您的所有帮助!