ADC Home > Reference Library > Technical Q&As > Legacy Documents > QuickTime >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

QuickTime CFM PowerPlug Libraries, Availability, Weak Links

The Code Fragment Manager supports the concept of "soft" or "weak" linking. If a library is soft-linked, the Process Manager runs your application, even if the library is missing. This means that the application does not die, even if a particular library is not installed, and the application can disable functionality based on library availability.

MPW PowerPC tools include the MakePEF tool with an additional flag that specifies that the exported symbols are weak. In this case the runtime architecture will try to resolve the CFM library, but won't fail if it can't. You can define that the library has weak linking by adding a magic tilde (~) character at the end of the -l option to MakePEF. For example, to soft link to QuickTimeLib you would do the following:

    MakePEF -l QuickTimeLib.xcoff=QuickTimeLib~ ...

You could also mark CFM libraries as weak using the Metrowerks PowerPC environment.

In the client program you can test that the CFM library was not loaded and for instance disable all functionality that depends on the CFM library (for example, no QuickTime CFM libraries present so "play movies" gets disabled).

Since the library only registers itself with Gestalt once, there's no way to unregister it if the user moves the library. This particular problem does not have any direct solutions, but there's an alternative way to determine if the library is loaded.

The solution is to check the address of one of the functions in the library before calling the library. The PowerPC Inside Macintosh documentation illustrates the technique:

extern int printf (char *, ...);
// ...
if (printf == kUnresolvedSymbolAddress)
        DebugStr("\printf is not available.");
else
    printf("Hello, world!\n");

QuickTime has a new Gestalt selector to determine whether it's safe to call the weak-linked library (gestaltQuickTimeFeatures). This function shows how to initialize QuickTime, for 68k and PowerPC:

Boolean    InitQuickTime(void)
{
    long         qtVersion;
    OSErr         anErr;
#ifdef powerc
    long         qtFeatures;
#endif

    anErr = Gestalt(gestaltQuickTime, &qtVersion);
    if (anErr != noErr)
        return false;        // no QT present

#ifdef powerc

// Test if the library is registered.
    anErr = Gestalt(gestaltQuickTimeFeatures, &qtFeatures);
    if ( !( (anErr == noErr)  &&  (qtFeatures
        & (1 << gestaltPPCQuickTimeLibPresent))  )) // not true
          return false;
#endif

    anErr = EnterMovies();
    if ( anErr == noErr)
        return true;
    else
        return false;        // problems initializing QuickTime
}

Both QuickTime Gestalt selectors are being tested for in the PowerPC case. You need to test both that QuickTime is present and that the QuickTime library is present.

A simple test to verify that things work properly is to exclude the PowerPlug CFM library from the extension file, or move it out from the folder while the application that needs the library is running.

If the application is unable to load the CFM library due to lack of space, the application might mysteriously die later, so it's important to always check that the libraries are loaded and available.

[May 01 1995]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.