Allegro 4.4 from Macports on Mac OS X 10.6.8 with GCC 4.2.1 not compiling! HELP!

Trying to get this to compile by issuing the following command:

gcc -Wall main.c -o main `pkg-config --cflags --libs allegro allegrogl`

but I get the following <a href=">error</a>.
Even with the option -m32 it doesn't compile. What do I do?
OS: Mac OS X 10.6.8
GCC: 4.2.1

Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 -program-prefix=i686-apple-darwin10 --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

Allegro: 4.4 installed from Macports for Snow Leopard
I'm very new to programming. I have no formal training in it. Everything I know is self taught. I'm trying to design a pong game by reading a book on game programming by Jonathon S. Harbour. The book uses Allegro 4.2 but I figured it's a little too old so I went with 4.4. Can someone help me out? Much appreciated.

Peter Hull

I figured it's a little too old

No kidding! :D But,

The error message seems fairly clear that you're compiling 64-bit and trying to link a 32-bit library (and an 'unknown' library for allegrogl.)

Did you install the universal variant of allegro?, i.e.

sudo port install allegro +universal

I don't think allegrogl is needed in the example so try omitting it from the command line.

If none of that works can you retry with -m32 and post the error message?



gcc -Wall main.c -o m -m32 `pkg-config --cflags --libs allegro`
This is the new command that I issued. This is the error that I get:

Undefined symbols:
  "_main", referenced from:
      start in crt1.10.6.o
     (maybe you meant: __mangled_main_address, __mangled_main )
ld: symbol(s) not found
collect2: ld returned 1 exit status


Edgar Reynaldo

gcc is picky about argument order. You need to separate the pkg-config calls into two separate calls, one for cflags, and one for libs

gcc -Wall -Wextra -Wshadow -g -o proggie `pkg-config --cflags allegro5` main.c `pkg-config --libs allegro5`

The --cflags argument has to come before your main.c, and the --libs argument has to go after it.

It also looks like you need to link to allegro main (OSX thing).


It finally compiled :o. Thanks Edgar for the tips :-*. I tweaked what you said a bit.

I uninstalled the version by Macports and installed the Allegro 4.4 by Fink. Then I finally typed the following command:
gcc -Wall -Wextra -m32 -o prog `allegro-config --cflags` main.c `allegro-config --libs`
and it worked. 8-)

Edgar Reynaldo

yeah, sorry, I was in Allegro 5 mode. Allegro 4 uses allegro-config, not pkg-config.

Glad you got it working. Happy coding!

Thread #617224. Printed from