[How-To] Install Allegro 5 and get it working on Code::Blocks

It is really easy!

First you need to add a new repository called ‘games’, there you can find allegro 5.
To add a new repository you can do it in 2 ways:

Open a terminal >

sudo zypper ar http://download.opensuse.org/repositories/games/openSUSE_13.2/ games
zypper ref

Or

YaST > Software Repositories > Add > “Specify URL” > http://download.opensuse.org/repositories/games/openSUSE_13.2/ > Next

After you are done, go to a terminal and type

zypper se allegro

If everything is working you will see bunch of libs.

Now for installing Allegro 5 you need to type:

sudo zypper in liballegro5_0 liballegro-devel liballegro_acodec5_0 liballegro_acodec-devel liballegro_audio5_0 liballegro_audio-devel liballegro_color5_0 liballegro_color-devel liballegro_dialog5_0 liballegro_dialog-devel liballegro_font5_0 liballegro_font-devel liballegro_image5_0 liballegro_image-devel liballegro_main5_0 liballegro_main-devel liballegro_memfile5_0 liballegro_memfile-devel liballegro_physfs5_0 liballegro_physfs-devel liballegro_primitives5_0 liballegro_primitives-devel liballegro_ttf5_0 liballegro_ttf-devel

And let OpenSUSE do the work!

After opensuse is done, open a Code::Blocks C Project and type

#include <allegro5/allegro5.h>

right click on “allegro5.h” and press “Open #include file…” if it opens you are good to go!

On Code::Blocks GO to Compiler Settings > Global Compiler Settings > Linker Settings > Add > GO to /usr/lib64 > Add these libs :

http://i.imgur.com/G6TY6WS.png

Pro tip: They are all together so you can Select the first, Hold Shift, then Select the last and Click OK!

You are almost done! Now for some testing Paste this :

#include <stdio.h>
#include <allegro5/allegro5.h>



int main(int argc, char **argv){

   ALLEGRO_DISPLAY *display = NULL;

   if(!al_init()) {
      fprintf(stderr, "failed to initialize allegro!
");
      return -1;
   }

   display = al_create_display(640, 480);
   if(!display) {
      fprintf(stderr, "failed to create display!
");
      return -1;
   }

   al_clear_to_color(al_map_rgb(0,0,0));

   al_flip_display();

   al_rest(10.0);

   al_destroy_display(display);

   return 0;
}


Build then RUN!

Proof : http://i.imgur.com/rihBiP2.png