Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dyld hook



Le 20 mai 04, ` 01:16, Brian Chrisman a icrit :

Is there a way to hook into dyld that will notify me when a dynamic library is about to be loaded and allow me to conditionally load that library from a location other than the default? Basically, we want to be able to load a set of libraries from one of two directories based on version and availability. We would only load the libraries from a given location if all the libraries in that location are of the correct version.

FYI: we currently accomplish similar functionality in XP using the __pfnDliNotifyHook2 callback.

In MacOS X, and Darwin, there's a mechanism to treat the case of incompatible libraries. In general, new versions are compatible with older ones, so there's no compatibility problems. But sometimes, big modifications requires to much work to keep this compatibility. In this case, you can create a library whose name is MyLibrary.1.dylib for the first version (and backwards compatible version). When changes are incompatible, create a new library with the name MyLibrary.2.dylib. Old programs are linked with the MyLibrary.1.dylib library and new with the MyLibrary.2.dylib : in this case it will work without problem. In order to linking automatically with the newest library, you may add a symbolic link MyLibrary.dylib to MyLibrary.2.dylib. See /usr/lib/ to have an idea how it is currently used.

There's a similar mechanism for frameworks, see /System/Library/Frameworks/System.framework for example (version are named with letters A, B, C).

If the library you use is not use by many programs, or change very often without backwards compatibility, try to use static library instead : in this case shared libraries are not useful and split your application in many parts where it can be monolithic.

--
Damien Bobillot
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.


References: 
 >dyld hook (From: "Brian Chrisman" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.