The process of creating or adapting to Carbon is a relatively straightforward process. In our example, we will take the Codewarrior Project produced by the 4D Plug-in Wizard and add the libraries needed to compile a Carbon Plug-in.
The first thing we need to make sure of is that we have downloaded the Carbon SDK from Apple. The Carbon SDK contains the CarbonLib we will need along with a few other files to compile. The Carbon SDK is located at: https://developer.apple.com/technical/. Once you have downloaded the SDK and unstuffed the file, place the Carbon Support folder inside the Metrowerks CodeWarrior folder. The Carbon Support folder should be located in the same location as folders such as MSL and MacOS Support.
We also need to run the CarbonHeaders.mcp project in our Carbon Support: CarbonLibHeadersPreCompiled folder. This project will build our Pre-compiled header files that we will need for compiling a Carbon project.
Now let's take a look at the CodeWarrior project. The first thing we want to do is add a new Target for our Carbon project. Under the Project menu choose "Create Target…". This will bring up a dialog that allows you to create a new Target for our project. We want to name the new project, and we want to clone the Debug PPC project as shown:
By cloning an existing Target we won't have to worry about setting up several of the Preferences.
The next step is to open the CodeWarrior Preferences for our new Target and go to the C/C++ Language Panel. Here at the bottom of this panel is where the Prefix file is set. We need to change this to CarbonHeaders.h. Once completed, click on the PPC Target panel and change the Type to '4DCB'. This needs to be done for the plug-in to work properly under Carbon.
We now need to update the Access Paths Panel so that our project will see the CarbonHeaders.h file. To do this, add the following paths to your project as shown below in the Access Paths Panel.
We are now ready to add our Carbon Libraries. Open the Carbon Support: CarbonLib: Stub folder. Inside the Stub folder you will see the CarbonLib. Drag this file into the Files tab of the CodeWarrior project under MacLibraries. Next, open up the MSL: MSL_C: MSL_MacOS: Lib: PPC folder. Inside this folder we want to drag the MSL C.Carbon.Lib and the MSL SIOUX.Carbon.Lib files to the ANSI Libraries folder in the Files tab of the CodeWarrior Project. Once completed, your Files tab for the Mac and ANSI Libraries should look like the following:
NOTE: These libraries are only available in CodeWarrior Pro6 and later.
Notice in the Target Column for the Carbon Project only the MSL C.Carbon.Lib, MSL SIOUX.Carbon.Lib, MSL RuntimePPC.Lib, and the CarbonLib files are marked. These are the only files that are needed to compile for Carbon.
You are now ready to compile your plug-in to run under Carbon and Mac OS X.