I have a problem here, I'm making a game using Allegro , I'm compiling the terminal and it's okay, there's only one, however, when I load an image of the failure while loading the image , the problem is not the code, I already tried to run code that ran on other computers, but in mine does not run. The most interesting thing is that if I run the code through the terminal using ./executavel.exe it runs normally as it should, the image appears and everything is quiet. Does anyone know how I can solve this? Leaving the doubt more explicit: The executable only runs when the execution is done by the terminal, when I give 2 executions of the error when loading the image. I can not tell you why of the error since when I do not load the image by clicking 2 times on the executable, it runs normally, which makes me think that the image is the problem. The question is, how to resolve knowing that it is not a wrong code issue since it normally compiles directly from the terminal?
Here is the code:
#include <stdio.h>
//puxa a biblioteca allegro
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_image.h>
//fixo de tamanho de tela
#define LAR 1280
#define ALT 720
int main(int argc, char *argv[]){
//inicialização da janela
ALLEGRO_DISPLAY *janela = NULL;
ALLEGRO_BITMAP *imagem = NULL;
//inicia allegro, caso erro da a msg
if(!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
al_get_standard_path(ALLEGRO_RESOURCES_PATH);
//cria a janela
janela = al_create_display(LAR, ALT);
if(!janela) {
fprintf(stderr, "failed to create display!\n");
return -1;
}
//inicia primitivos
//al_init_primitives_addon();
//inicia a extenção de imagens
if(!al_init_image_addon()){
fprintf(stderr, "Falha ao carregar image addon");
}
//carrega imagem
imagem = al_load_bitmap("imagem.jpg");
if (!imagem){
fprintf(stderr, "Falha ao carregar imagem!\n");
return -1;
}
//preenche a tela com alguma cor
al_clear_to_color(al_map_rgb(0,0,0));
//desenha imagem
al_draw_bitmap(imagem, LAR/2 - (al_get_bitmap_width(imagem)/2),
ALT/2 - (al_get_bitmap_height(imagem)/2), 0);
//atualiza a tela
al_flip_display();
//pausa a execução
al_rest(10.0);
//destroi imagem
al_destroy_bitmap(imagem);
//destroi variavel janela
al_destroy_display(janela);
return 0;
}
My Mac is Yosemite 10.10.5
F.A.Q
Yes the image has the same name that I refer to in the code
Yes it is in the same folder as the executable
Yes when I compile I call -lallegro_image
I was told that it might be a permission problem, but I do not know how to solve this, I'm noob on OSX