[AD] MacOS X shared library

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I have an issue to discuss.
Currently, the OSX port defines a main() replacement inside the lib, and the user has to provide an END_OF_MAIN() that defines _mangled_main (which the lib real main() calls). So _mangled_main is undefined inside the lib. This leads to problems when linking to a shared lib: under OSX prebinding is enabled by default and that means no undefined symbols must be present at link time... Currently we disable prebinding and use some hacks to make it link with the undefined symbol _mangled_main. But if an addon library that builds as shared lib links with the shared Allegro, problems arise again, and the addon has to use the same hacks Allegro currently uses (penalising performances: prebinding decreases load time).

I have made some changes to the makefile so that when creating Allegro as a shared lib, it is split into two chunks, like under Unix: the shared lib itself, which has no undefined symbols, and a very small static lib named liballeg-main.a, which just has the real main() function that refers to _mangled_main. This way when calling allegro-config both libs are linked in and no problems arise, and addons could just link to the shared (now prebound!) chunk risking no errors. The only "bad" thing in this I can see is the fact we now have two libs, and some other things have to be updated (like the ProjectBuilder app template, which should now link to alleg-main, and the enduser package docs, which should report that it doesn't contain alleg-main, thus it can't be used to code, but just to run third party Allegro apps)

--
Angelo Mottola
a.mottola@xxxxxxxxxx

PS: it'd be nice if we could use the SF compile farm to produce the OSX enduser package; there's a script in misc/ that generates it after the shared lib has been build. This could be put in the Allegro downloads page...





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/