Allegro on Xcode

Hello Guys!
I'm new on this site (this is the first thing that i write). And i have a question... I program on mac (Xcode) but I am new in this, and when i wanted to install allegro, i could only download it's files. I don't know how to include the library (#include <allegro.h>) because when i write this Xcode tell me:

'allegro.h file not found'

Where i have to save the folder of allegro?

Pd. Pardon my bad English, such as you can see i don't speak English very well.

Thanks

Anyone can help me? :'(
I can probably help with this. I've not used Allegro, but it was pretty easy to get a window up and running.

First off, how did you install Allegro? I would advise against downloading files. Just install using Homebrew instead:
brew install allegro

I'm not going to explain the ins and outs of brew here - it's a package manager for OS X. If you need to read more, check out their site.

Once you've installed Allegro, create a new Xcode project. Make sure this is a C++ console application.

In your project settings for your application target, go to Build Settings. In the Header Search Paths option, add '/usr/local/include' (minus the quotes). This is where brew installs the headers (or, at least, where it places a symlink to the header directory).

Then, in the Build Phases tab, expand the Link Binary With Libraries option. Click the plus sign, followed by 'Add Other...'. Navigate to /usr/bin/lib and add liballegro.dylib and liballegro_main.dylib. Again, these are both symlinks that brew creates. You'll see the two libraries appear in the left hand side of your Xcode pane.

Once that's done, you've got everything you need to run a simple Allegro example. I wrote this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <allegro5/allegro.h>

int main(int argc, char **argv)
{
    if (!al_init())
    {
        std::cerr << "Failed to init allegro!";
        return 1;
    }
    
    ALLEGRO_DISPLAY* pDisplay = al_create_display(640, 480);
    
    if (!pDisplay)
    {
        std::cerr << "Failed to create display!";
        return 1;
    }
    
    al_clear_to_color(al_map_rgb(147, 147, 147));
    al_flip_display();
    al_rest(3.0);
    al_destroy_display(pDisplay);
    
    return 0;
}


This'll create a grey window for three seconds. That should be it. The only other thing to note is that Allegro is modular. You'll have to add libraries as you use them (for example, you'll need to link to the liballegro_audio.dylib if you want to use their audio functions).

Edit: Super duper grey screen proof image: http://postimg.org/image/nf5ktupyp/
Last edited on
love you! :')
Topic archived. No new replies allowed.