[SOLVED]SDL OpenGL linker errors
Posted: Sat Mar 06, 2010 9:38 pm
So I'm trying to make a space invaders game with SDL and OpenGL. I keep getting these linker errors
I've seen on google that the mainCRTStartup thing means that either I did main in my program wrong, which I'm pretty sure its right
or you have to set your entry point to wWinMainCRTStartup, that didn't work.
as for the others I have no clue. Lots of things have said that its due to not including the libraries right... but I'm pretty sure they are all there I'm linking the following libraries to my project
I think that should be all... Here is my code
if anyone has any clue what the problem might be, I would be very grateful... one more thing, I have tried putting this code into a clear project, a clear win32project, and a clear console project... I've been trying to get it to compile for 3 days now...
Code: Select all
Main.obj : error LNK2019: unresolved external symbol _atexit referenced in function _SDL_main
Main.obj : error LNK2019: unresolved external symbol __imp__printf referenced in function _SDL_main
Main.obj : error LNK2001: unresolved external symbol __fltused
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
Code: Select all
int main(int argc, char *argv[])
as for the others I have no clue. Lots of things have said that its due to not including the libraries right... but I'm pretty sure they are all there I'm linking the following libraries to my project
Code: Select all
sdl.lib sdlmain.lib opengl32.lib glu32.lib
Code: Select all
#include <stdio.h>
#include <sdl.h>
#include <sdl_opengl.h>
#include <gl/gl.h>
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
int main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_EVERYTHING | SDL_OPENGL) < 0)
{
printf("Unable to init SDL %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
SDL_WM_SetCaption("Sp4c3 1nv4d3rz", NULL);
//Set icon at the topleft to be this
SDL_Surface* image = SDL_LoadBMP("icon.bmp");
int colorkey = SDL_MapRGB(image->format, 255,0,255);
SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
SDL_WM_SetIcon(image, NULL);
//OGL attributes :P
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_Surface* screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_OPENGL);
if (!screen)
{
printf("Unable to set %ix%i video: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, SDL_GetError());
return 1;
}
//OGL viewport and stuff like buffer clear color
glViewport(0, 0, screen->w, screen->h);
glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0); //This will need to be changed...
glClearColor(0.0, 0.0, 0.0, 0.0);
//quit?
bool done = false;
//main game loop
while (!done)
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
{
done = true;
break;
}
case SDL_KEYDOWN:
{
if (event.key.keysym.sym == SDLK_ESCAPE)
{
done = true;
}
break;
}
}
}
//Draw GL stuff!
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex2f(400.0, 160.0);
glVertex2f(320.0, 440.0);
glVertex2f(480.0, 440.0);
glEnd();
SDL_GL_SwapBuffers();
}
return 0;
}