Jump to content
  • Advertisement
Sign in to follow this  
pyrosim

OpenGL and SDL Trouble

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I try to compile this code: ------------------------------------------------------------ #include <iostream> #include <string> #include <SDL/SDL.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <SDL/SDL_openGL.h> using namespace std; #include "defines.h" /* Define SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, amd APP_NAME*/ int main(int argc, char *argv[]) { if(SDL_Init(SDL_INIT_VIDEO)<0) { cerr<<"Error: SDL_Init\n"<<SDL_GetError()<<endl; return 1; } atexit(SDL_Quit); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); SDL_GL_SetAttribute(SDL_GL_RED_SIZE,5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,6); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,5); if(SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,SDL_OPENGL)==NULL) { cerr<<"Error: SDL_SetVideoMode\n"<<SDL_GetError()<<endl; return 1; } SDL_WM_SetCaption(APP_NAME,NULL); // Put OpenGL rendering commands here (don't know them yet) SDL_GL_SwapBuffers(); SDL_Delay(3000); return 0; } ------------------------------------------------------------------------- In MS visual C++ 6, I get these errors: --------------------Configuration: main - Win32 Debug-------------------- Compiling... main.cpp Linking... main.obj : error LNK2001: unresolved external symbol _SDL_GL_SwapBuffers main.obj : error LNK2001: unresolved external symbol _SDL_GL_SetAttribute Debug/main.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. main.exe - 3 error(s), 0 warning(s) ------------------------------------------------------------------------- I have set up the linker configuration as: ------------------------------------------------------------------------- kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/main.pdb" /debug /machine:I386 /nodefaultlib:"libcmt.lib" /out:"Debug/main.exe" /pdbtype:sept ------------------------------------------------------------------------- So I am including the SDL.lib and SDLmain.lib files and excluding the libcmt.lib file. I dont understand why it wont compile and can't find any reference on the web. Is there another library I need to add for the openGL commands? If anyone knows what is going on and can help please do.

Share this post


Link to post
Share on other sites
Advertisement
You need to set the attributes before you call SDL_Init.
You also need to link to Opengl32.lib and glu32.lib.

Share this post


Link to post
Share on other sites
Don't know if this helps but you also need to change some project setting to Multithreaded debug dll.

Share this post


Link to post
Share on other sites
If i change to the multithreaded DLL my errors become:
--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
Linking...
main.obj : error LNK2001: unresolved external symbol _SDL_GL_SwapBuffers
main.obj : error LNK2001: unresolved external symbol _SDL_GL_SetAttribute
SDLmain.lib(SDL_main.obj) : error LNK2001: unresolved external symbol __pctype
SDLmain.lib(SDL_main.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
Debug/main.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

main.exe - 5 error(s), 0 warning(s)

Share this post


Link to post
Share on other sites
Try taking out
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>

SDL_opengl.h includes them itself (and is better to use...)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!