Public Group

# using SDL - but cant recognise opengl

This topic is 4130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've setup SDL under Visual Studio 03 to use with OpenGL, and I can include the SDL.h and SDL_opengl.h headers alright, but when I try to run OpenGL commands the compiler doesnt recognise them and gives the 'unresolved external symbol' error, and I cant really figure out why. I setup SDL by: Copied SDL.lib and SDLmain.lib to Microsoft Visual Studio .NET 2003\Vc7\lib Copied the SDL .h files in the zip's include folder to Microsoft Visual Studio .NET 2003\Vc7\Include\SDL Copied SDL.dll to Windows\System32 Set the Project Properties --> Cplusplus --> Code Generation --> Runtime Library to: Multi-threaded DLL Set the Project Properties --> Linker --> Input --> Additional Dependencies to: SDL.lib SDLmain.lib I can compile this code ok:
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"

int main(int argc, char* args[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Quit();

return 0;
}


But when I try to include an OpenGL command I get the 'unresolved external symbol' error:
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"

void initOpenGL()
{
glClearColor(0,0,0,0);
}

int main(int argc, char* args[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Quit();

return 0;
}


Would anyone have any ideas what might be the problem, as none of the guides I read mentioned anything additional being required to get SDL_opengl up and running. Thanks all

##### Share on other sites
Firstly SDL_Init(SDL_INIT_EVERYTHING) doesnt actually set up OpenGL, to do that oyu need to set a screen mode using:
SDL_SetVideoMode(width, height, bpp, SDL_OPENGL);

And also SDL.lib doesnt include the openGL lib. You will need to link openGL too, usually its called opengl32.lib (if not you may have to google for its name).

##### Share on other sites
ahh ok I see, I stuck opengl32.lib into 'Additional Dependencies' with the other libraries and it compiles now, thanks much ;)

• 10
• 18
• 14
• 18
• 15