Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Allegro 4.4 from Macports on Mac OS X 10.6.8 with GCC 4.2.1 not compiling! HELP!

This thread is locked; no one can reply to it. rss feed Print
Allegro 4.4 from Macports on Mac OS X 10.6.8 with GCC 4.2.1 not compiling! HELP!
i_am_a_mage
Member #16,796
January 2018
avatar

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="https://pastebin.com/4MTFL7DN>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
Member #1,136
March 2001

Quote:

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?

Pete

i_am_a_mage
Member #16,796
January 2018
avatar

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
Major Reynaldo
May 2007
avatar

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).

i_am_a_mage
Member #16,796
January 2018
avatar

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
Major Reynaldo
May 2007
avatar

Go to: