![]() |
|
Mac OS X distributing program as .app file |
xlightningz
Member #14,967
March 2013
![]() |
Hello, I recently compiled allegro and created frameworks for Xcode following this guide. It seemed easy enough, and I've had no problems running my programs in Xcode, but I'm having trouble creating a .app bundle for use on other computers. If I archive and distribute the program through Xcode, I get the following error when attempting to open the application bundle: "Pong cannot be opened because of a problem. Check with the developer to make sure Pong works with this version of Mac OS X. You may need to reinstall the application. Be sure to install any available updates for the application and Mac OS X." Pong is the name of my Xcode project. If I open the .app file located at '~/Library/Developer/Xcode/DerivedData/Pong-gwxwmndkwnmimufqwperucqdimwh/Build/Products/Debug', it runs fine on my computer, but I can't run it on any other Mac. In both cases, the contents of the .app file include the needed frameworks and a Unix executable file. I did attempt to find an answer to my problem online, but the closest thing I could find was an answer that Allegro must be installed on every computer the App is going to be run on. This seemed to be contradicted by other information I read, and if it was true, I still don't understand why the .app bundle created by distributing the program doesn't even work on my computer. I must admit that I'm a very inexperienced programmer and this is the first time I've tried to create a .app bundle for any program. I'd really appreciate any help! |
Trent Gamblin
Member #261
April 2000
![]() |
Open Console.app from Utilities and see what messages are printed. Is there a button with that dialog to show any details?
|
xlightningz
Member #14,967
March 2013
![]() |
There wasn't a show details button in the error message, but I found the crash report in Console. I'm attaching a .txt file with the crash report, and I'll copy the seemingly relevant parts into this post. Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000 Application Specific Information: dyld: launch, loading dependent libraries Dyld Error Message: Symbol not found: __al_mangled_main Referenced from: /Library/Frameworks/AllegroMain-5.0.framework/Versions/5.0.7/AllegroMain-5.0 Expected in: flat namespace in /Library/Frameworks/AllegroMain-5.0.framework/Versions/5.0.7/AllegroMain-5.0
The only solution to this error that I can find online is to fix the main declaration. Is this not correct? int main(int argc, char **argv) { //code }
|
Trent Gamblin
Member #261
April 2000
![]() |
That is right, but some things you have to do: 1) #include <allegro5/allegro.h> in the file main is defined in.
|
xlightningz
Member #14,967
March 2013
![]() |
Thanks for the help. 1) I'm already doing this. |
Trent Gamblin
Member #261
April 2000
![]() |
Ah. I don't know what the problem is. I always build Allegro as static libraries so if it's something to do with frameworks I wouldn't know.
|
xlightningz
Member #14,967
March 2013
![]() |
Okay, thank you for trying. I'll try to research bundling frameworks in general while I wait for another answer here. UPDATE: Something I did fixed the __al_mangled_main error, but I'm not sure exactly what it was. I'm getting a different error now, and this one makes more sense. When I open the application on another computer, it searches for the frameworks in /Library/Frameworks. I have the copy files build phase set up, and I can see the frameworks in .app/Contents/Frameworks, but the code can't find them. Can someone please help me with fixing this problem? |
Elias
Member #358
May 2000
|
Easiest solution probably is to static link instead of using the frameworks. -- |
xlightningz
Member #14,967
March 2013
![]() |
Okay, I went with frameworks because there was a very clear guide to getting them for my OS and my version of Xcode. Can you point me to a good guide for installing static libraries? EDIT I changed my mind about going with static libraries. Frameworks just seem so much more natural. I used install_name_tool to change the install directory of the frameworks to @executable_path/../Frameworks so it can be loaded from the application bundle. My new problem is that Allegro-5.0.framework is loaded, but AllegroMain-5.0 still searches for it in /Library/Frameworks. It doesn't seem like anyone here will be able to help me, but I figured I'd give this one last bump just in case. |
Ingo Maurischat
Member #14,951
February 2013
|
Hello You have to change the @executable_path in all libraries / framework too. e.g. sudo install_name_tool -change @loader_path/liballegro.5.0.dylib @executable_path/../Resources/libs/liballegro.5.0.8.dylib liballegro_main.5.0.8.dylib
|
xlightningz
Member #14,967
March 2013
![]() |
Thanks for the reply. I'm afraid I don't exactly understand what you're saying. Every framework had the install_name set to @executable_path/../Frameworks. Something I did messed something up, so I reinstalled the frameworks. I made sure the correct install_name was set, and now I'm getting a new error, yet again. Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000 Application Specific Information: dyld: launch, loading dependent libraries Dyld Error Message: Library not loaded: /opt/local/lib/libfreetype.6.dylib Referenced from: /Volumes/VOLUME/Pong.app/Contents/MacOS/../Frameworks/AllegroTTF-5.0.framework/Versions/5.0.10/AllegroTTF-5.0 Reason: image not found Is it required for the computer to have freetype installed, or can I somehow include that with my application as well? UPDATE: I finally got my application to run on another computer! I simply added libfreetype.6.dylib to the Framework copy files build phase in Xcode. After that, I used the following terminal command to tell AllegroTTF where to find the library. sudo install_name_tool -change /opt/local/lib/libfreetype.6.dylib @executable_path/../Frameworks/libfreetype.6.dylib /Library/Frameworks/AllegroTTF-5.0.framework/Versions/5.0.10/AllegroTTF-5.0 Thanks to Ingo Maurischat for pointing me towards the -change flag of install_name_tool when I was only using -id before. Also, thanks to Trent Gamblin for working with me to try and solve my problem. |
Ingo Maurischat
Member #14,951
February 2013
|
To check all dependencies of all used frameworks and libs the otool command is very useful. e.g. otool -L libfreetype.6.dylib this give you the needed information to go on with install_name_tool
|
|