0
Guys have a problem here, I’m playing a game using the Allegro, I am compiling by the terminal and ta ok, there is only one however, when I load an image of the fault when loading the image, the problem is not the code, I have tried to run code that ran on other computers, but on mine does not run. The interesting thing is that I run the code through the terminal using . /executavel.exe it runs normally as it should, the image appears and everything 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 clicks on the error executable when loading the image. I can not say why 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 solve knowing that it is not a matter of wrong code since it compiles normally straight 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 executable folder
Yes when I compile I call -lallegro_image
I was told that it could be permission problem, however I do not know how to solve it, I am Noob in OSX
What is your compiler and version of Allegro. If you don’t know, send the tutorial you used to install
– krystalgamer
@krystalgamer, my compiler is gcc and Allegro is 5.0
– Alexandre Gomes