Converting from Carbon CFM to Mach-O

These steps apply to plugins compiled with Codewarrior 8 or higher. (You can build Mach-O plugins with Codewarrior 8, but you need version 9 or 10 to debug them.)

1. Go to the Targets pane and create a new target by cloning the Carbon CFM target.

2. Select the new target and modify its Target Settings as follows. (NOTE: all file and directory names are case-sensitive.)

Target Settings
  • Choose new target directory for the Mach-O version. (It can be the same as that for the CFM version, but then you should give it a different name in the PPC Mac OSX Target pane.)
  • Select Mac OSX PowerPC Mach-O as the linker.
Access Paths
  • Add {Compiler}MacOS X Support as the first System Path. You will probably need to keep MSL and/or MacOS Support, for access to any of their include files that are not in MacOS X Support.
  • Add {OS X Volume}usr/lib. (This is a hidden directory where bundle1.o lives.)
  • DO NOT add the System Frameworks path at this time. Let Codewarrior do it automatically when you add the frameworks. (See below.)
PPC Mac OSX Target
  • Change Project Type to Bundle Package.
  • Type in Bundle Name, which will be the name of the file (bundle) containing your plugin.
  • Set HFS Creator to FIN3 and HFS Type to FINX.
PPC CodeGen Mach-O
  • Change Struct Alignment to match that of the CFM plugin. In my case, I use 68K struct alignment. The default (PowerPC), apparently aligns 32-bit integers on 32-bit boundaries, which means it probably will cause weird bugs in your code.
PPC Mac OS X Linker
  • Change Export Symbols to Use #pragma.
  • Clear the Main Entry Point textbox, if there is anything in it.
Debugger Settings

These are my personal debugger preferences, but they are not required to build the plugin.

  • Uncheck Stop on application launch.
  • Uncheck Log System Messages.

3. Navigate to the Files pane, and modifiy the libraries as follows.

4. Navigate to the Frameworks pane. In Finder, navigate to System/Library/Frameworks. Drag any frameworks you need onto the Frameworks pane in Codewarrior. At the least you will probably need Carbon.framework and System.framework. (I also use IOKit.framework, but do not add it unless you know you need it.) The first time you drag a framework to the Frameworks pane, Codewarrior automatically adds the path for the framework to your Access Paths.

If you have upgraded from Codewarrior 8 (or earlier) to Codewarrior 10, you may encounter an error "identifier 'restrict' redeclared". To fix this, go to the C/C++ Language pane in Target Settings and check Enable C99 Extensions.