![]() |
|
embedding allegro framework in games on mac os x? |
TheLHP
Member #10,535
January 2009
|
Hello, I know during the installation of allegro on mac os x, there is the option to do 'sudo install-framework EMBED=1' to have the framework embedded in the game bundle so they'll work on other macs. So I'm assuming its already installed that way. However, when i compile my games in xcode (3.1) the framework is not in the app bundle, doesn't work on my other macs that dont already have allegro installed, and there's no obvious way to build it WITH it embedded. Any help would be much appreciated, |
Thomas Harte
Member #33
April 2000
![]() |
'sudo install-framework EMBED=1' has the effect of building a version of the Allegro framework that is suitable for embedding into projects. However, the ever-decaying Project Builder project template doesn't attempt to do so. You are absolutely right that there is no obvious way to adjust the template. However, there is a non-obvious way. On your target, right click and select "Add->New Build Phase...->New Copy Files Build Phase". In the menu that then comes up, switch the copy target from 'Resources' to 'Frameworks'. Close that dialogue, then do a copy drag (ie, start dragging, then hold down alt/option before dropping — same as the the Finder) of the Allegro framework from the 'Link Binary with Libraries' phase to your new copy phase. Next time you build, Xcode will embed the framework for you. Assuming it was correctly built as embeddable, you should then be good to go. A good way to test on your own machine is to temporarily remove Allegro.framework from /Library/Frameworks and try to run your application. A little movie is attached of me doing the above steps in Xcode 3.1. I'm a bit of a traditionalist, so I use the 'Condensed' Xcode layout, but I'm sure you can figure out what to do if you're an 'All-in-One' or 'Default' sort of guy. [My site] [Tetrominoes] |
TheLHP
Member #10,535
January 2009
|
hmm, i followed your steps exactly, (what video were you talking about? I'm dumb!) and in the app bundle the allegro framework IS in there, but it will not run on my other macs. I even tried rebuilding it with those steps on 1 of my ppc macs and it would not run on any of the other ppc's. I know it's not the macs themselves because the allegro demo game runs just fine on them. It just seems like xcode isn't making it clear to the app that it needs to use the framework in the app bundle.. Thanks! |
Ron Novy
Member #6,982
March 2006
![]() |
Click the paper clip at the top of Thomas Harte's post and a little list will pop up with the video file in it ---- |
Thomas Harte
Member #33
April 2000
![]() |
TheLHP said: i followed your steps exactly, (what video were you talking about? I'm dumb!) and in the app bundle the allegro framework IS in there, but it will not run on my other macs. The video is attached to my post — click the paperclip next to my name to see the list of attachments. In this case there should be just one, which is a mov. Anyway, it doesn't matter since if the file is both linked against and automatically copied to your Frameworks folder then you performed the necessary steps correctly. It sounds like for some reason Allegro has not made the framework embeddable for whatever reason. As a test, open an instance of the terminal, go to /Library/Frameworks and try: otool -D Allegro.framework/Versions/Current/Allegro If Allegro is embeddable it would print: @executable_path/../Frameworks/Allegro.framework/Versions/4.2.2/Allegro Hopefully it won't for you. In which case you can do: install_name_tool -id @executable_path/../Frameworks/Allegro.framework/Versions/4.2.2/Allegro Allegro.framework/Allegro And like magic, your framework will be embeddable. Clean and rebuild your program, see if your problem is gone. [My site] [Tetrominoes] |
TheLHP
Member #10,535
January 2009
|
Ok, But when I try running the otool on my ppc mac (running Tiger) that's setup for allegro development, it returns and when i try the 'install_name_tool -id @executable_path/../Frameworks/Allegro.framework/Versions/4.2.2/Allegro Allegro.framework/Allegro' i get: install_name_tool: can't open input file: Allegro.framework/Allegro for writing (Permission denied) This wouldn't be a problem if there was a way to make the apps universal so they'll work on Powerpc's after being compiled on intel; can it be done? This would be a lot easier too as I could do all of my development on my better intel mac. I really appreciate all your help, haha, thanks:D |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
I'd guess that the bad file descriptor errors are the result of Permission Denied (so naturally it can't read them). Are you familiar with chown so you can get permission? They all watch too much MSNBC... they get ideas. |
Thomas Harte
Member #33
April 2000
![]() |
Oh, looks like Allegro copies its stuff so that everything is flagged modifiable by the root user only. To fix the permission/file descriptor issues, do this first: su [any username with administrator privileges] If the username has a space in it, you'll need to add a slash before it, e.g. if your user was "The LHP" you'd need: su The\ LHP That'll require you to enter the password for that user. You can then use: sudo install_name_tool [the stuff I said before] To have Allegro make a universal version of itself rather than one that is processor specific, you need to go almost right the way back to the beginning and do ./fix.sh macosx-universal rather than ./fix.sh macosx prior to letting Allegro make and install itself. Allegro's build system is tetchy and ever more broken (Apple keep moving goalposts, Allegro has barely any Mac developers), with the effect that it doesn't seem to successfully make a universal version for a lot of Intel users with 10.5. So it's probably safest to do the universal build on a PowerPC. Maybe you'll even get lucky and this build will make an embeddable version of the framework without you having to do a lot of manual UNIXy stuff yourself. I have an Intel machine without Allegro installed (well, close enough — I forego the UNIX-style installation that scatters things among obscure fixed-path locations, with the result that I can install and uninstall my copy of Allegro very easily), so if I can test anything then feel free to attach it. While it's a matter of testing your installation, I think it remains relevant for this section of the forums. My assumption is that you'll probably need to do a separate universal build on every machine you want to use for development. You can't simply copy the Framework because Allegro also relies upon the static library liballeg-main.a. Alternatively, grab the Framework and liballeg-main.a and take them to your development machine. As I don't allow Allegro to squirrel things away, I don't recall where it normally puts liballeg-main.a. Personally, I tend to let Allegro 'make' but not 'make install', I copy the complete set of headers into the Framework along with liballeg-main.a, then copy that by hand and set Xcode to reference it in my Allegro project template. No obscure UNIXyness, no fuss. It's absolutely a personal preference decision though, a lot of people love UNIX and commandlines and so on. EDIT: Arthur's suggestion of chown would work as an alternative to su and sudo. Similarly, I guess you could go to /Library/Frameworks in the Finder, bring up the Info on Allegro.framework and set the permissions in there (it'll ask for an administrator account username if yours isn't an administrator account and for your password) and make sure you have the privilege level for you set to 'Read & Write' under Sharing & Permissions, as I do here: {"name":"598946","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/5\/c51023699f34cb9fa46b56afa3cc635d.png","w":345,"h":912,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/5\/c51023699f34cb9fa46b56afa3cc635d"} [My site] [Tetrominoes] |
TheLHP
Member #10,535
January 2009
|
Ok, now I'm getting some good results! I tried using Su on my ppc mac, did the install_name_tool, and now it returns successful when doing the otool test thing, And after fighting with terminal and xcode for awhile, I got my ppc mac to compile for universal, and now the apps compiled on that machine work on my intel. As with the embedding problem, I've attached a test program (Intel) for you, Thomas, it supposed to have the framework embedded. Let me know how it runs. Thanks |
Thomas Harte
Member #33
April 2000
![]() |
Yep, yep, runs just fine. And at just 45% CPU, which is refreshing for an Allegro program. I'm on an original Core Duo MacBook Pro 2.16Ghz from mid-2006 if that helps add detail to the off-topic issue. [My site] [Tetrominoes] |
TheLHP
Member #10,535
January 2009
|
Ok, good to know the embedding works. |
Thomas Harte
Member #33
April 2000
![]() |
Sorry, wading way off topic for this section of the forum, so I'll be brief. For years the standard advice in the Allegro world was "occupy 100% of the CPU, who cares?". That's fine for vanilla Pentium PCs, but obviously atrocious for any computer designed around thermal or power usage considerations, including every current Mac and 90% of PCs. Obviously you've done something to limit CPU usage as much as you can, which is very good. And didn't cause my fans to go into can-almost-no-longer-hear-the-audio mode. [My site] [Tetrominoes] |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
Didn't DOS itself use 100% CPU in a busy loop looking for keystrokes sitting at the C:\ prompt? I remember reading many years ago about active CPU cooling via a reverse thermocouple, and when they ran Linux on it, and Linux used the hlt instruction to save CPU usage, frost formed on this cooler, and when the CPU got warm under load, this frost melted and shorted out the motherboard They all watch too much MSNBC... they get ideas. |
Thomas Harte
Member #33
April 2000
![]() |
Arthur Kalliokoski said: Didn't DOS itself use 100% CPU in a busy loop looking for keystrokes sitting at the C:\ prompt? [...] It wouldn't surprise me. Of the versions of Windows I possess, Windows 2000 is a lot more efficient in a virtual machine than Windows 98, so I suspect the whole DOS line might be blighted. Completely unnecessary, of course, because the display can continue to function without CPU intervention and the keyboard input generates interrupts. And so does the clock, for the purposes of TSRs. But that was an age before anyone cared about power management, when the computer had one fan only, on the PSU. I definitely had a P200 that was passively cooled, so anecdotally I reckon the turning point for shoving fans everywhere was after that, and I guess the reaction to use as little power as possible so as to keep the fans off when possible is around the same period. And now that laptops are the dominant consumer form factor, preserving battery power is a concern in addition to thermal issues. And you heard it here first: don't use Linux, it'll frost up your motherboard real bad. [My site] [Tetrominoes] |
|