Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Installing Allegro on Mac (OS X 10.9.5) Allegro 5.0.11

This thread is locked; no one can reply to it. rss feed Print
Installing Allegro on Mac (OS X 10.9.5) Allegro 5.0.11
Smartypants
Member #15,897
March 2015

-----
EDIT: I used the command: g++ hello.cpp -o hello `pkg-config --cflags --libs allegro-5 allegro_main-5`

And it worked. I am not sure how so please feel free to explain
-----

Hello!

I followed to steps to build and install Allegro 5 from their wiki (found here: https://wiki.allegro.cc/index.php?title=Main_Page) and seemingly succeeded with no problems.

allegro was installed to the following (as the wiki suggests) /usr/local/include and usr/local/lib and I have confirmed allegro is there.

I then wrote the following code in vim:

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

int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display = NULL;

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

display = al_create_display(640, 480);

if(!display)
{
fprintf(stderr, "failed to create display!\n");
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;
}

I am new to using Unix and have only ever compiled c++ programs with g++ that were simple hello world files with no libraries needed.

Therefore after searching around on the internet I tried the following commands:

g++ hello.cpp -o hello `pkg-config --libs allegro-5`

resulting in the following:

Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: __al_mangled_main)
ld: symbols not found for architecture x86_64
clang: error: linker command failed with exit code 1

BTW, I used homebrew to install dependencies instead of macports

brew install pkg-config brew install zlib etc...

I think its a problem with things not being linked.

What am I doing wrong?

Elias
Member #358
May 2000

And it worked. I am not sure how so please feel free to explain

There's several libraries which you all need to link to: allegro_main, allegro, allegro_image, allegro_primitives, allegro_color, allegro_font, allegro_ttf, allegro_audio, allegro_acodec, allegro_memfile, allegro_physfs, allegro_native_dialog

You forgot the first one at first (which is technically required everywhere but in practice only on OSX).

Or you can build Allegro with the "monolith" option, then you will only have a single library with everything: allegro_monolith

--
"Either help out or stop whining" - Evert

Go to: