Entropy.ch Discussion Forums Forum Index Entropy.ch Discussion Forums
Discussion forums about Mac OS X software development.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

making mac bundles

 
Post new topic   Reply to topic    Entropy.ch Discussion Forums Forum Index -> General / Guestbook
View previous topic :: View next topic  
Author Message
Will Stokes
Guest





PostPosted: Mon Oct 06, 2003 20:04    Post subject: making mac bundles Reply with quote

hi, I ran across your web site via google. I'm developing a photo album
package called Album Shaper using Qt. it's available on linux/freebsd via
X, and also under windows. my next release, which is coming out VERY soon,
I'd like to include mac os x. my friend just got a new powerbook and I'm
about to start toying with getting it working over there. getting the code
compiled shoudl be no problem, and I believe creating a bundle shoudl be
pretty much straight forward. you appears to have a lot of experience
getting programs to work on mac os x so I thought I'd ask you a few
questions. Smile

1.) it appears the apple guys modified gcc to include a -bundle option.
what exactly does this do? do it just create a folder like blah.app and
the correct file structure within with the linked binary when linking
together all your stuff at hte end of a build?

2.) if I have extra files like images, text, etc, where shoudl I put them
in the bundle? right now I have various helper files with Album Shaper
(images, handbook, text, translations, etc). where should each of these
folders go in the bundle? I assume all in one place, but where?

3.) you spoke on your site about proper installation of mac os x software.
once I have this bundle created, what is the best way to distribute it to
mac os x users? are there installers I can go about creating? do users
just download a zipped up .app bundle and put it somehwere on their
ssytem? what method for compressing the .app bundle is standard?

I'm very very new to this stuff, and whiel I've gleaned a lot from reading
online, as you can see I still have a few questions. any help you can give
me I would very much appreceiate. thanks!
-Will Stokes
Back to top
liyanage
Site Admin


Joined: 22 May 2003
Posts: 1104
Location: Zurich, Switzerland

PostPosted: Mon Oct 06, 2003 20:43    Post subject: Reply with quote

Quote:

hi, I ran across your web site via google. I'm developing a photo album
package called Album Shaper using Qt. it's available on linux/freebsd via
X, and also under windows. my next release, which is coming out VERY soon,
I'd like to include mac os x.


Interesting, but keep in mind that Mac users have high expectations regarding user interfaces (and that excludes X11 by definition Smile ). I personally don't really use any X11 packages on the Mac unless I really have to because I don't like the look and feel of these apps.


Quote:

1.) it appears the apple guys modified gcc to include a -bundle option.
what exactly does this do? do it just create a folder like blah.app and
the correct file structure within with the linked binary when linking
together all your stuff at hte end of a build?


No. That's a bit confusing, because the term "Bundle" is used for two different things.

1.) One is what you wrote above: a directory layout convention for applications and other stuff residing on the file system.

From http://developer.apple.com/macosx/win32porting/

Quote:

Bundles

A bundle is a directory in the Mac OS X file system that stores executable code and software resources related to that code but is displayed in the Finder as a single icon. There are several kinds of bundles; you will be most interested in the application bundle, which is the kind of bundle used to package and distribute Mac OS X applications.

Bundles decrease user confusion and keep the file system from appearing cluttered. In addition, they help make sure that an application always uses the proper versions of any needed libraries, and they make it possible for a single application to contain support for multiple geographical locales.

When users double-click an application bundle's icon, Mac OS X executes the associated application. Mac OS X uses bundles to store an application and all the files it needs, including character strings in multiple languages, images, plug-ins, shared libraries, frameworks, and arbitrary data files (also called resources).




2.) But a bundle is also a particular type of the Mach-O binary output format which is used for dynamic libraries

From the gcc man page:

Quote:

-bundle
Produce a Mach-o bundle format file. See man ld(1) for more infor-
mation.


And from http://fink.sourceforge.net/doc/porting/shared.php

Quote:

2.1 Shared Libraries vs. Loadable Modules

One Mach-O feature that hits many people by surprise is the strict distinction between shared libraries and dynamically loadable modules. On ELF systems both are the same; any piece of shared code can be used as a library and for dynamic loading.

Mach-O shared libraries have the file type MH_DYLIB and carry the extension .dylib. They can be linked against with the usual static linker flags, e.g. -lfoo for libfoo.dylib. However, they can not be loaded as a module. (Side note: Shared libraries can be loaded dynamically through an API. However, that API is different from the API for bundles and the semantics make it useless for an dlopen() emulation. Most notably, shared libraries can not be unloaded.)

Loadable modules are called "bundles" in Mach-O speak. They have the file type MH_BUNDLE. Since no component involved cares about it, they can carry any extension. The extension .bundle is recommended by Apple, but most ported software uses .so for the sake of compatibility. Bundles can be dynamically loaded and unloaded via dyld APIs, and there is a wrapper that emulates dlopen() on top of that API. It is not possible to link against bundles as if they were shared libraries. However, it is possible that a bundle is linked against real shared libraries; those will be loaded automatically when the bundle is loaded.



The gcc option -bundle refers to the second kind of bundle.


From reading your questions, it sounds like you need information about "Application Bundles", and not loadable modules. So don't worry about the gcc option, that has nothing to do with what you want to achieve.

Quote:

2.) if I have extra files like images, text, etc, where shoudl I put them
in the bundle? right now I have various helper files with Album Shaper
(images, handbook, text, translations, etc). where should each of these
folders go in the bundle? I assume all in one place, but where?


I can't explain the entire Application Bundle structure to you here, but that kind of stuff usually goes into the "Resources" subfolder.

The full details about Application Bundles are here:

http://developer.apple.com/documentation/MacOSX/Conceptual/SystemOverview/AppPackaging/index.html

Quote:

3.) you spoke on your site about proper installation of mac os x software.
once I have this bundle created, what is the best way to distribute it to
mac os x users?


There is clearly one particular way which is the best way: an Application Bundle which contains all its material and does not depend on *anything* outside of its directory, including any shared libraries (which requires some particular linker settings, see the "-dylib_install_name" option to the linker in the "ld" man page.

If you deliver that, then users can install it by simply dragging the app to their application folder. They can also uninstall it easily, just by moving the application to the trash. You should not use an installer which installs components of your application all over the file system.

And this kind of clean application is usually delivered on a compressed Disk Image (.dmg) file. This is the ultimate convenience for users. They can download and double-click it, and it mounts a virtual volume on which you can put the application itself as well as any documentation or other material you'd like (not online help, that should go into the app bundle). Users can the drag the app to their "Applications" folder, maybe read your README, and then unmount the virtual volume and trash the .dmg file.

This is how it should be.

You should not use the packaged style which I use for my (non-GUI, UNIX) packages for real applications.


If your app is X11 based, then the next Mac OS, Panther / 10.3, will be able to launch your app by just double-clicking onto the main binary. The Finder seems to see that you linked against the X11 libraries, and it will launch the X11 window server automatically.

So you might be able to get away without any of the app bundle stuff, but you should still make it self-contained.


Quote:

are there installers I can go about creating? do users
just download a zipped up .app bundle


That is also a possibility if you don't want to do the .dmg thing (maybe because there really is no additional material). I've done that for some of my apps.

Quote:

and put it somehwere on their
ssytem?


Yes, if the app does not depend on any external shared libraries, or other external resources whose path was hard-coded. Such hard-coding is what you must avoid at all costs. There have been some really ugly packages which installed libs into /usr/local etc.. A big no-no for a GUI app.



Quote:

what method for compressing the .app bundle is standard?


You can use .zip or .sit, or the .dmg thing I mentioned above. I even used .tar.gz once. Mac OS X comes with Stuffit Expander which can decompress a lot of formats.


Quote:

I'm very very new to this stuff, and whiel I've gleaned a lot from reading
online, as you can see I still have a few questions. any help you can give
me I would very much appreceiate. thanks!


Apple has excellent documentation online, check out their ADC site, and read the links I mentioned above.

Make sure that it's a well-behaved app. Users will thank you for that Smile
Apple has some truly great concepts in OS X, and sometimes they are really simple things like the bundle concept, but with big ease of use impact for end users and you should use that to your advantage...

Good luck Smile
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Will Stokes
Guest





PostPosted: Mon Oct 06, 2003 21:58    Post subject: thanks! Reply with quote

Thanks a lot. you've provided me with some great info, and links. Smile Qt for mac does not require X11. That's the beauty of qt apps, they run natively on virtually any system you want (win32, linux, mac os x).
-Will
Back to top
liyanage
Site Admin


Joined: 22 May 2003
Posts: 1104
Location: Zurich, Switzerland

PostPosted: Mon Oct 06, 2003 22:32    Post subject: Re: thanks! Reply with quote

Will Stokes wrote:
Thanks a lot. you've provided me with some great info, and links. Smile Qt for mac does not require X11. That's the beauty of qt apps, they run natively on virtually any system you want (win32, linux, mac os x).
-Will


I know. I thought you might be using the Qt / Aqua version.

Still, make sure it behaves like a Mac app Smile

And have fun...
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Entropy.ch Discussion Forums Forum Index -> General / Guestbook All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group