#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <SDL/SDL.h>
// The functions are not shown to save space
void DrawPixel(SDL_Surface *screen, int x, int y,Uint8 R, Uint8 G, Uint8 B);
void Slock(SDL_Surface *screen);
void Sulock(SDL_Surface *screen);
SDL_Surface *screen;
int main(int argc, char *argv[])
{
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
{
std::cout << "Unable to init SDL: " << SDL_GetError() << std::endl;
exit(1);
}
atexit(SDL_Quit);
screen=SDL_SetVideoMode(640,480,32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);
if ( screen == NULL )
{
std::cout << "Unable to set 640x480 video: " << SDL_GetError() << std::endl;
exit(1);
}
/////////////////////////
///////////////////////// This is the erroring section...
//BEGIN DRAWING//////////
/////////////////////////
/////////////////////////
Slock(screen);
for(int x=0;x<640;x++)
{
for(int y=0;y<480;y++)
{
DrawPixel(screen, x,y,256,0,0);
}
}
Sulock(screen);
SDL_Flip(screen);
//////////////////////
//////////////////////
//END DRAWING/////////
//////////////////////
//////////////////////
return 0;
}
Dev-CPP and Cone3D examples
I get:
g++.exe ../../../Templates/main.o SDL_Test_private.res -o "SDL Test.exe" -L"C:/DEV-CPP/lib" -L"C:/Dev-Cpp/lib" -mwindows -lmingw32 -lSDLmain -lSDL -liberty
../../../Templates/main.o(.text+0x11c):main.cpp: undefined reference to `Slock(SDL_Surface*)'
../../../Templates/main.o(.text+0x15d):main.cpp: undefined reference to `DrawPixel(SDL_Surface*, int, int, unsigned char, unsigned char, unsigned char)'
../../../Templates/main.o(.text+0x17c):main.cpp: undefined reference to `Sulock(SDL_Surface*)'
Execution terminated
When I try to compile... Yes I am including the SDL libs and all... it was working until I added my drawing routine... help.
[edited by - Maxd Gaming on February 7, 2004 11:41:39 PM]