Right, so I'm using a new Ubuntu, a new Codeblocks and I've downloaded and installed libsdl-image1.2 and -dev along with all the other sdl libraries so I can do my SDL tutorial. Everything seemed to be working fine until I was told to start using functions from "SDL_image.h", for example "IMG_Load".
Even though I've included the library (#include <SDL_image.h> or #include <SDL/SDL_image.h> - it makes no difference) I immediately get a:
undefined reference to `IMG_Load'
Meanwhile things like SDL_LoadBMP work fine.
Synaptic maintains that the libraries are actually there so clearly I need to manually install something somewhere or rather point Codeblocks in the right direction, I'm just not entirely sure how to go about that.
The code is as follows by the way:
#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
#include <SDL_image.h>
void pause();
int main(int argc, char *argv[])
{
SDL_Surface *screen = NULL, *background = NULL, *zozor = NULL, *pine = NULL;
SDL_Rect pos_bgrnd, pos_zozor, pos_pine;
pos_bgrnd.x=0;
pos_bgrnd.y=0;
pos_zozor.x=500;
pos_zozor.y=260;
pos_pine.x=260;
pos_pine.y=500;
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("SDL Images", NULL);
SDL_WM_SetIcon(SDL_LoadBMP("sdl_icone.bmp"), NULL);
screen = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE);
background = SDL_LoadBMP("lac_en_montagne.bmp");
SDL_BlitSurface(background, NULL, screen, &pos_bgrnd);
zozor = SDL_LoadBMP("zozor.bmp");
SDL_SetColorKey(zozor, SDL_SRCCOLORKEY, SDL_MapRGB(zozor->format, 0, 0, 255));
SDL_SetAlpha(zozor, SDL_SRCALPHA, 150);
SDL_BlitSurface(zozor, NULL, screen, &pos_zozor);
pine = IMG_Load("sapin.png");
SDL_BlitSurface(pine, NULL, screen, &pos_pine);
SDL_Flip(screen);
pause();
SDL_FreeSurface(background);
SDL_Quit();
return EXIT_SUCCESS;
}
void pause()
{
int continue = 1;
SDL_Event event;
while (continue)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continue = 0;
}
}
}
I'm following a tutorial from http://www.siteduzero.com/ where they use codeblocks, just not codeblocks for Ubuntu it seems (you're only given installation instructions for Mac and Windows) :?
Any help would be greatly appreciated :)
William