Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » OSX Snow Leopard

Credits go to Arthur Kalliokoski, Evert, and LennyLen for helping out!
This thread is locked; no one can reply to it. rss feed Print
OSX Snow Leopard
OnlineCop
Member #7,919
October 2006
avatar

I upgraded from Leopard to Snow Leopard. When I tried to compile any of my previously-working projects, I get several warnings and a compile error:

liballeg-main.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
liballeg.dylib, file was built for i386 which is not the architecture being linked (x86_64)

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

This is the file I'm trying to compile:

#SelectExpand
1 2#include <allegro.h> 3 4int main() 5{ 6 allegro_init(); 7 8 allegro_message("Output!"); 9 10 return 0; 11} END_OF_MAIN()

And this is the command-line arguments I'm using:

g++ test00.cpp `allegro-config --libs`

where `allegro-config --libs` expands to:

-L~/usr/local/lib -framework Cocoa -lalleg-main -lalleg

So I blew away the entire drive, reinstalled Mac OSX Snow Leopard from disk, installed (and updated) XCode and X11, and followed the suggestions on the following pages in various orders, but with the same results.

I've also used MacPorts and hoped it would work for me with both of these variations:

sudo port install allegro
sudo port install allegro +univeral

I've tried installing to the following directories as well (by redefining the CMAKE_INSTALL_PREFIX in cmake/ccmake):

/usr/local
/opt/local
~/usr/local
~/opt/local

I'm at a loss, and getting annoyed that I can no longer compile Allegro projects anymore. Any suggestions? I'll give screen dumps if you want them.

Arthur Kalliokoski
Second in Command
February 2005
avatar

This is Allegro 5 you're trying to use? `allegro-config --libs` is for 4.4x and below, isn't it? My command line to compile 4.9+ looks more like
gcc -s -O2 -Wall myprog.c -o myprog `pkg-config --libs allegro_audio-4.9`

They all watch too much MSNBC... they get ideas.

LennyLen
Member #5,313
December 2004
avatar

This is Allegro 5 you're trying to use?

It's not, based on the test-code snippet he pasted.

edit: if it was the cmake reference that made you think it might be A5, A4.4 uses cmake as well.

Arthur Kalliokoski
Second in Command
February 2005
avatar

The first link he posted said: "Anyway, yes, pre-4.9 Allegro is limited to 32 bit on OS X."

http://www.allegro.cc/forums/thread/604122/866489#target

They all watch too much MSNBC... they get ideas.

Evert
Member #794
November 2000
avatar

The answer is here:

OnlineCop said:

liballeg-main.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
liballeg.dylib, file was built for i386 which is not the architecture being linked (x86_64)

Default compiler output changed for Snow Leopard, from 32 bit to 64 bit. Allegro 4, unfortunately, can only be compiled in 32 bit because it uses deprecated APIs that are only available in 32 bit.
Set the compiler to compile your project in 32 bit mode (-m32) and everything will be fine.

Or upgrade to Allegro 5, which doesn't have the issue (but does have an entirely new API).

OnlineCop
Member #7,919
October 2006
avatar

Most of the projects I've got on my plate still run off of 4.4 and earler :-/ so I'm running into this issue.

Evert said:

Set the compiler to compile your project in 32 bit mode (-m32) and everything will be fine.

Is it as simple as that? Update my various Makefiles (or reconfigure cmake to include this flag) for each project and try again to see if this resolves the issue?

I tried compiling for this, and it didn't throw up any compiler errors. Kudos!

It doesn't run, with a "

dyld: Library not loaded: liballeg.4.4.dylib

" error, but that may just be that I need to update my paths.

Thanks, Evert!

Felix-The-Ghost
Member #9,729
April 2008
avatar

Hey hey remember when I couldn't get any Allegro 4 program to compile on my Mac at school? Yeah it was Snow Leopard. Maybe I should try it again.

==========================
<--- The ghost with the most!
---------------------------
[Website] [Youtube]

OnlineCop
Member #7,919
October 2006
avatar

I tried installing Allegro from the SVN checkout (changing the install path through ccmake from /usr/local to /opt/local).

I had already added /opt/local to my various paths:

set CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/opt/local/include
set C_INCLUDE_PATH=$C_INCLUDE_PATH:/opt/local/include
set LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
set MANPATH=$MANPATH:/opt/local/share/man
set PATH=$PATH:/opt/local/bin:/opt/local/sbin

I've had to use MacPorts in order to get the dependency files (like cmake, gettext, etc.) that Allegro needs to compile, and then when it finally compiled my program above correctly (with the -m32 switch), I would get an error when running it:

dyld: Library not loaded: liballeg.4.4.dylib
Referenced from: allegro_test
Reason: image not found

From this mail archive, I got some good pointers as to find out WHAT was going on:

Quote:

Using "otool -L", you can see the install names recorded in a binary. For example, here's "/usr/bin/true":

$ otool -L /usr/bin/true
/usr/bin/true:
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)

Note the full paths to libgcc_s and libSystem.

I ran this on the file, and this was my output:

$ otool -L allegro_test 
allegro_test:
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 15.0.0)
	liballeg.4.4.dylib (compatibility version 4.4.0, current version 4.4.2)
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.29.0)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 38.0.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 751.29.0)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1038.32.0)

Notice that "liballeg.4.4.dylib" did not have a path to it: "/opt/local/lib/liballeg.4.4.dylib"

Because of this, it wouldn't run but it was compiling just fine. Copying and/or linking (using ln /opt/local/lib/liballeg.4.4.dylib liballeg.4.4.dylib) would resolve this and get the program to run, but since it did not have that "/opt/local/lib/" prefix tacked onto the front it, it was not resolving from "just any old path".

To remedy this, I had tried setting DYLD_LIBRARY_PATH to /opt/local/lib as was recommended all over the internet, but that caused MORE problems when trying to run it (it threw up more error messages about OTHER things not being able to be located correctly now).

::bang head on wall::

So I started over, cleaned up all the files, and got rid of everything. I installed Allegro directly from MacPorts: sudo port install allegro and let it choose all the dependencies for me.

Now when I compile, it all works fine.

So while it's a version older than SVN, it works. So I guess I'm happy that Allegro now compiles!

Now if I could only get the DuMB music library to compile...

Evert
Member #794
November 2000
avatar

OnlineCop said:

To remedy this, I had tried setting DYLD_LIBRARY_PATH to /opt/local/lib as was recommended all over the internet, but that caused MORE problems when trying to run it

Did you try LD_LIBRARY_PATH as well? Did you add that directory to the path or did you override what else may have been in there?

I don't know what you did wrong, but Allegro 4 SVN should compile and install properly (I did it yesterday or the day before).

OnlineCop
Member #7,919
October 2006
avatar

Evert said:

Did you try LD_LIBRARY_PATH as well? Did you add that directory to the path or did you override what else may have been in there?

Yes, see my post:

OnlineCop said:

set CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/opt/local/include
set C_INCLUDE_PATH=$C_INCLUDE_PATH:/opt/local/include
set LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
set MANPATH=$MANPATH:/opt/local/share/man set PATH=$PATH:/opt/local/bin:/opt/local/sbin

This always worked fine from SVN on Leopard, but when I tried Snow Leopard, it kept blowing up on me.

Felix-The-Ghost
Member #9,729
April 2008
avatar

OnlineCop said:

dyld: Library not loaded: liballeg.4.4.dylib
Referenced from: allegro_test
Reason: image not found

Same message I kept getting when you walked me with Allegro on Snow Leopard.

==========================
<--- The ghost with the most!
---------------------------
[Website] [Youtube]

OnlineCop
Member #7,919
October 2006
avatar

Were you able to copy the file (or link to it) into the current directory and get it working then?

I think that was the only problem with the SVN version: when compiled, the library was not referencing the full path; it was referencing the local directory only, which is why it couldn't be found.

Felix-The-Ghost
Member #9,729
April 2008
avatar

Never got it fixed.
Never found that file.

==========================
<--- The ghost with the most!
---------------------------
[Website] [Youtube]

OnlineCop
Member #7,919
October 2006
avatar

I think you had appended to your CMAKE_INSTALL_PREFIX the '~' symbol, so instead of /usr/local it was ~/usr/local. So it's possible that the file was located there.

Anyway, now that it's working, I'd say do it all 100% through Macports for now. And if that gets working, you can always go the alternate routes and try to install it from SVN or something...

Felix-The-Ghost
Member #9,729
April 2008
avatar

I'm not posting from the same Mac I tried to install on last year -- but I am interested in trying to install it again (This is Snow Leopard I'm on)

Is there like a [complete, working] guide somewhere cause I don't remember anything I did, nor have I even read the perhaps complete steps in this thread. I just want to be able to compile and package programs on Mac after trying for a year.

==========================
<--- The ghost with the most!
---------------------------
[Website] [Youtube]

OnlineCop
Member #7,919
October 2006
avatar

That's essentially why I posted my findings. If others' mileage vary, hopefully they'll post here as well.

I'd say to start with Macports. Unless you HAVE to have the most-recent SVN checkout, go with the kinda-updated version that Macports has to offer.

By the way, who keeps Allegro updated on Macports? Does someone submit the newest version/sources somewhere to point them to the recent version? Is that why doing sudo port install allegro only installs Allegro 4 and not 5?

Evert
Member #794
November 2000
avatar

Is there like a [complete, working] guide somewhere cause I don't remember anything I did, nor have I even read the perhaps complete steps in this thread.

Just did this:

  • Get current SVN snapshot

  • configure with CMake: set the CMAKE_INSTALL_PREFIX to /Users/username. Left all else at the default settings, if in doubt set CMAKE_OSX_ARCHITECTURES to "i386".

  • run "make -j2" followed by "make install"

Then for testing:

  • Copy examples/exbitmap to ~/tmp, and try loading a bitmap. Worked fine.

From .bashrc:

export DYLD_LIBRARY_PATH=/opt/intel/Compiler/11.0/056/lib/:$CUDA_HOME/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib:/usr/local/lib:/opt/local/lib:$CUDA_HOME/lib
export C_INCLUDE_PATH=$C_INCLUDE_PATH:$HOME/include:/opt/local/include
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$HOME/include
export LIBRARY_PATH=$LIBRARY_PATH:$HOME/lib:/opt/local/lib

That's all. Remember to open a new shell if you change your .bashrc (or simply source .bashrc).

EDIT

OnlineCop said:

who keeps Allegro updated on Macports?

Whoever is interested in maintaining it.

Felix-The-Ghost
Member #9,729
April 2008
avatar

Can I still do it without root access since I'm on a school's computer?
I remember having to do everything differently because of it last time.

I've gotten stupid[er] in regards to installing over a years time of not even having my old computer (now I got it back)

I seem to remember having a higher version of Allegro than the norm but still lower than 4.9. Is the official release 4.2 or 4.4? I seem to remember having 4.4 and the "official" release 4.2 since like one guy was reportedly working on the 4.4 branch. Or something. Maybe Trent.

==========================
<--- The ghost with the most!
---------------------------
[Website] [Youtube]

Evert
Member #794
November 2000
avatar

Can I still do it without root access since I'm on a school's computer?

Of course. The steps I posted above are all done as a normal user (that's why modified CMAKE_INSTALL_PREFIX and installed it locally).

Quote:

Is the official release 4.2 or 4.4? I seem to remember having 4.4 and the "official" release 4.2 since like one guy was reportedly working on the 4.4 branch.

Not sure what you mean by "official release". Allegro 4.4 is the current stable release from the Allegro 4 branch.

OnlineCop
Member #7,919
October 2006
avatar

He's right. You can download the 4.4 version from the SVN. In fact, using MacPorts will install version 4.4.1, so it no longer points to 4.2 anymore.

Now, MacPorts will install, by default, to /opt/local, so if you wanted all of its dependencies and other files, you will need to compile the sources for Mac yourself. THEN you will be able to change the path to ~/opt/local or ~/usr/local, or any other directory you want to use.

Besides that, though, please let us know how your success bodes, so we can know whether we should stick those instructions into the Allegro Wiki.

Felix-The-Ghost
Member #9,729
April 2008
avatar

We can pretty much just say I'm stupid and have no idea what MacPorts is.
I know where the SVN is but I can't even comprehend anything else.

>Just downloaded the "allegro-4.4.1.1.zip" from SVN.
>Extracted
>FFFFFFFFFFF
>started terminal
>checked keep in dock :P
>cd /Users/sstutzman/Downloads/allegro
>FFFFFFFFFFF
>typed 'cmake'
>nothiing happens
>I go North
>I go West
>I decide to ascend the spooky stairs
>I have drowned
>Insert coin
>I start downloading "cmake-2.8.3-Darwin-universal.dmg"
>Wow that's big
>Obligatory "that's what she said"
>I mount "cmake-2.8.3-Darwin-universal.dmg"
>Move the package itself to desktop
>Try to install by not reading anything and clicking 'continue' etc.
>Need administrators password
>rage
>don't know where to install it
>read thread again
>realize thread doesn't go over cmake install
>realize I misspelled 'nothing' earlier
>type 'die' into terminal
>I die
>hesitate to insert coin

Its been a year since I did any of this stuff.
I seem to remember having to... download cmake somehow ???

==========================
<--- The ghost with the most!
---------------------------
[Website] [Youtube]

OnlineCop
Member #7,919
October 2006
avatar

  1. MacPorts from sources (not the precompiled binary)

  2. Open Terminal (/Applications/Utilities/Terminal.app)

  3. `cd` to the directory where this file was extracted

  4. Run "./configure --prefix=$HOME/opt/local" with any additional options you would like to set (see "./configure --help" for all options)

  5. Add your $HOME/opt/local directory to your paths (see OP)

  6. Run port install allegro

You can run other optional packages, such as lua (be sure to use the "+universal" flag: port install lua +universal to make it 32-bit compatible). Packages like cmake and the other dependencies are auto-magically downloaded as a dependency for Allegro.

No need to call 'cmake' or 'make' yourself: MacPorts does it all for you.

Go to: