Error (0xc000007b) [With SDL_image]

Hi, everyone!

I’m currently working on Code::Blocks and I don’t know if I’m the only one with this problem, but it’s a fatal error which says: “Unable to start the application (0xc000007b).”

This error is not this troublesome, but I can’t work with SDL_image (which I need for my projects.)
SDL_mixer and SDL_gfx work just fine. (I have a music format problem with SDL_mixer, though.)

I installed and linked everything so it shouldn’t show any error, but there was.
C::B asked me at first to install SDL2_image.dll (I’m using SDL 1.2, not 2.0). I download SDL2_image.dll, then (0xc000007b) appears and I can’t execute the program.
No compilation problem, but when I execute… (0xc000007b)…

I already checked on Internet, testing each version of SDL_image (with 32 and 64 bit system) but nothing has worked so far.
I even reinstalled C::B… No luck!

Here is my script:

#include
#include <stdlib.h>
#include <stdio.h>
#include <SDL\SDL.h>
#include <SDL_mixer.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <SDL_rotozoom.h>
#define TIME 20

typedef struct
{
char key[SDLK_LAST];
int mousex,mousey;
int mousexrel,mouseyrel;
char mousebuttons[8];
char quit;
} Input;

void UpdateEvents(Input* in)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_KEYDOWN:
in->key[event.key.keysym.sym]=1;
break;
case SDL_KEYUP:
in->key[event.key.keysym.sym]=0;
break;
case SDL_MOUSEMOTION:
in->mousex=event.motion.x;
in->mousey=event.motion.y;
in->mousexrel=event.motion.xrel;
in->mouseyrel=event.motion.yrel;
break;
case SDL_MOUSEBUTTONDOWN:
in->mousebuttons[event.button.button]=1;
break;
case SDL_MOUSEBUTTONUP:
if(event.button.button != SDL_BUTTON_WHEELUP && event.button.button != SDL_BUTTON_WHEELDOWN)
in->mousebuttons[event.button.button]=0;
break;
case SDL_QUIT:
in->quit = 1;
break;
default:
break;
}
}
}

/*int Draw(SDL_Surface *surface, char *image_path, int x_pos, int y_pos)
{
SDL_Surface image = IMG_Load (image_path);
if (!image)
{
printf (“IMG_Load: %s\n”, IMG_GetError ());
return -1;
}
SDL_Rect rcDest = {x_pos, y_pos, 0, 0};
SDL_BlitSurface(image, NULL, surface, &rcDest);
SDL_Flip(surface);
return 0;
}
/

void draw(SDL_Surface* screen,SDL_Surface* fond,SDL_Rect &position)
{
SDL_BlitSurface(fond, NULL, screen, &position);
SDL_Flip(screen);
}

void play(Mix_Music* track, int n)
{
Mix_PlayMusic(track, n);
}

int main ( int argc, char** argv )
{
Input in;
memset(&in,0,sizeof(in));
SDL_Surface *screen = NULL, *fond = NULL, *fondVide = NULL, *fond2 = NULL, *rotation = NULL; //, *mario = NULL, *sol = NULL;
SDL_Rect position, position2;
position.x = 16;
position.y = 9;
position2.x = 325;
position2.y = 165;
double angle = 0;
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(800, 450, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption(“The Game”, NULL);
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024);
Mix_Music *track01 = NULL;
track01 = Mix_LoadMUS(“Silver City.mp3”);
fond = SDL_LoadBMP(“Agent From Heaven.bmp”);
fondVide = SDL_LoadBMP(“carrenoir.bmp”);
fond2 = SDL_LoadBMP(“cb.bmp”);
if(screen == NULL)
{
fprintf(stderr, “Impossible : %s\n”, SDL_GetError());
exit(EXIT_FAILURE);
}
int AcTime = 0, PrevTime = 0;
while(!in.key[SDLK_ESCAPE] && !in.quit)
{
UpdateEvents(&in);
if (in.mousebuttons[SDL_BUTTON_MIDDLE])
{
AcTime = SDL_GetTicks();
if (AcTime - PrevTime > TIME)
{
angle += 9;
PrevTime = AcTime;
}
else
{
SDL_Delay(TIME - (AcTime - PrevTime));
}
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
rotation = rotozoomSurface(fond2, angle, 1.0, 1);
SDL_BlitSurface(rotation, NULL, screen, &position2);
SDL_FreeSurface(rotation);
SDL_Flip(screen);
}
if (in.mousebuttons[SDL_BUTTON_LEFT])
{
draw(screen,fond,position);
play(track01, -1);
}
if (in.mousebuttons[SDL_BUTTON_RIGHT])
{
draw(screen,fondVide,position);
}
if (in.key[SDLK_s])
{
draw(screen,fond2,position2);
}
/if (in.key[SDLK_a])
{
Draw(sol, “Sol.png”, 80, 0);
Draw(mario, “Mario.png”, 376, 172);
}
/
}
//SDL_FreeSurface(mario);
//SDL_FreeSurface(sol);
SDL_FreeSurface(fondVide);
SDL_FreeSurface(fond);
SDL_FreeSurface(screen);
Mix_CloseAudio();
SDL_Quit();
return EXIT_SUCCESS;
}

I colored the relevant parts, and will comment them:

  • The yellow part is the inclusion of SDL_image.h, the library I can’t use.
  • The green part is a function in order to draw an image.
  • The blue parts are for the calling of this function.

This program is for testing everything I have, so that’s normal if it seems hazardous.

Dear developers, if you’ve overcome this error, I’d like to know how you did it!

Thanks!

Have you called
Code:
IMG_Init()

before calling any
Code:
IMG_*

functions ?

Unfortunately, it doesn’t work either…

I am using SDL 2.0 with code::blocks without any problems, and i have also used SDL 1.* with code::blocks just fine.

Maybe there is some problem using SDL_image 2.0 with SDL 1.* ?

As mr_tawan said, call IMG_Init(flags); with the correct flags and then check for errors:

Code:
if (!(IMG_Init(flags) & flags))
{
std::cout << IMG_GetError() << std::endl;
}

maybe that can provide you with some more info on what’s going on…

Other than that… tried debugging?

I downgraded SDL_image because I don’t think I need the 2.0 version.
So I have SDL 1.2 and SDL_image 1.2.
I’ve been debugging all the time, but the problem is SDL_image itself.
The problem showed when I tried to execute the program.
I said “showed” because I tried a manip earlier and the error doesn’t show anymore. However, when I push the “A” button, the PNG image don’t show, and I think that’s my final problem.
(SDL2_image.dll is not necessary anymore, by the way.)