Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Using allegro on QT, it crushes

This thread is locked; no one can reply to it. rss feed Print
Using allegro on QT, it crushes
ErdrickBass
Member #16,696
June 2017

Hello everyone

I have used allegro a couple of months ago on VisualStudio. So I'm somewhat new but I know a little about allegro.

I'm doing an application on QT and I want to include Allegro to build an specific window.

1. I downloaded the files From Here. I downloaded the MSVC 11 one.

2. I copied the content on the respective folder (lib, include, bin). On my qt folder (C:\Qt\5.9\msvc2015\lib)

3. I added this lines to my .pro file changing depending on what librarys I use:

Quote:

LIBS += C:/Qt/5.9/msvc2015/lib/allegro-5.0.10-md.lib \
C:/Qt/5.9/msvc2015/lib/allegro-5.0.10-monolith-md.lib \
C:/Qt/5.9/msvc2015/lib/allegro_primitives-5.0.10-md.lib \
C:/Qt/5.9/msvc2015/lib/allegro_color-5.0.10-md.lib

4. I ran some examples I found and all of them crush unless I make some changes. This example runs:

#SelectExpand
1#include <iostream> 2#include <allegro5/allegro.h> 3#include <allegro5/allegro_primitives.h> 4 5int main(){ 6 7 if(!al_init()){ 8 cout << "failed to dislpay" "Failed to initialize Allegro.\n"<< endl; 9 return -1; 10 } 11 al_init_primitives_addon(); 12 ALLEGRO_DISPLAY *display = al_create_display(640,480); 13 14 if (!display){ 15 cout << "failed to dislpay" << endl; 16 return -1; 17 } 18 al_clear_to_color(al_map_rgb(50,10,70)); 19 //al_draw_triangle(10,10,20,10,15,50, al_map_rgb(255,0,0), 1.0); 20 al_flip_display(); 21 22 al_rest(10.0); 23 24 al_destroy_display(display); 25 26 return 0; 27}

If I uncomment the line:

Quote:

al_draw_triangle(10,10,20,10,15,50, al_map_rgb(255,0,0), 1);

The program stops working. The same happens with other lines like the ones related to font or drawing

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

ErdrickBass
Member #16,696
June 2017

Thank you, it worked. It was a problem with the version as you said.

I downloaded the binaries from the section "Allegro 5.2 binary packages" for MSVC. But it didn't have all the necesary files, only some.

I made a proyect on Visual studio and downloaded the Nuget package for that proyect and copied the missing files from this proyect from the "packages" folder, it had a filder called Allegro.5.2.2.1.

I changed the references from my .pro so it points to the files I copied from the proyect on visual studio:

Quote:

LIBS += C:/Qt/5.9/msvc2015/lib/allegro.lib \
C:/Qt/5.9/msvc2015/lib/allegro_monolith-static.lib \
C:/Qt/5.9/msvc2015/lib/allegro_primitives.lib \
C:/Qt/5.9/msvc2015/lib/allegro_color.lib

I leave what I did in case someone else has the same problem.

By the way I didn't made the proyect on Visual Studio because I needed to add an interface for my QT proyect

Go to: