Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page >

Forcing an Application to Run Translated

Assuming that the application meets the criteria described in “What Can Be Translated?”, applications that have only a PowerPC binary automatically run as translated on an Intel-based Macintosh. For testing purposes, there are several ways that you can force applications that have a universal binary to launch as a PowerPC binary on an Intel-based Macintosh:

Each of these methods is described in this section.

Make a Setting in the Info Window

You can manually set which binary to execute on an Intel-based Macintosh computer by selecting the “Open using Rosetta” option in the Info window of the application. To set the option, click the application icon, then press Command-I to open the Info window. Make the setting, as shown in Figure A-1.


Figure A-1  The Info window for the Calculator application

Figure A-1 The Info window for the Calculator application

Use Terminal

You can force a command-line tool to run translated by entering the following in Terminal:

ditto -arch ppc <toolname> /tmp/toolname
/tmp/tool

Modify the Property List

You can set the default setting for the “Open using Rosetta” option by adding the following key to the Info.plist of your application bundle:

<key>LSPrefersPPC</key>
<true/>

This key informs the system that the application should launch as a PowerPC binary and causes the “Open using Rosetta” checkbox to be selected. You might find this useful if you ship an application that has plug-ins that are not native at the time of shipping.

Use the sysctlbyname Function

The exec_affinity routine in Listing A-2 controls the preferred CPU type for sublaunched processes. You might find this routine useful if you are using fork and exec to launch applications from your application.

The routine calls the sysctlbyname function with the "sysctl.proc_exec_affinity" string, passing a constant that specifies the CPU type. Pass CPU_TYPE_POWERPC to launch the PPC executable in a universal binary. (For information on sysctlbyname see Mac OS X Man Pages.)

Listing A-2  A routine that controls the preferred CPU type for sublaunched processes

cpu_type_t exec_affinity (cpu_type_t new_cputype)
{
    cpu_type_t ret;
    cpu_type_t *newp = NULL;
    size_t sz = sizeof (cpu_type_t);
 
    if (new_cputype != 0)
        newp = &new_cputype;
 
     if (sysctlbyname("sysctl.proc_exec_affinity", 
            &ret, &sz, newp, newp ? sizeof(cpu_type_t) :  0) == -1) {
        fprintf(stderr, "exec_affinity: sysctlbyname failed:  %s\n",
                strerror(errno));
        return -1;
    }
    return ret;
}


< Previous PageNext Page >


Last updated: 2006-07-24




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.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2006 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice