Lightwave Plugin Compilation on MacThis tutorial explains how to compile a C/C++ plugin for Lightwave on the Macintosh without using CodeWarrior, just freely
available software. I have highlighted issues you may encounter and work arounds. These instructions should work in either
Mac OS9 or OSX using Classic, although they have only been tried in OSX using Classic. I have only built this on a PowerPC
based system, and do not know if it can be done on an Intel based Mac system. If you require any additional help, or would
like me try porting your plugin simply email me.
Instructions
After installing MPW, download all the updates from http://developer.apple.com/tools/mpw-tools/updates.html and install them. Installing these was a matter of overwriting the existing files where MPW was originally installed.
Next install the Lightwave SDK of choice somewhere appropriate.
First you must compile the server library, follow these steps to do that. If at any time you run into problems refer to the
notes section at the bottom for further help.
Launch MPW Shell
Then from the menus select "Directory" -> "Set Directory..." and then choose the "source" folder under the SDK installation.
Then from the menus select "Build" -> "Create Build Commands...".
Next enter the program name as "server.lib" and select "Static Library" and "PowerPC Only".
Then click "Source Files..." and choose "servdesc.c", "username.c", "startup.c", and "shutdown.c" and then click "Add" then
"Done".
Then click "Include Search Paths..." and choose the "include" folder under the SDK installation and then click "Add" then
"Done".
Then click "PowerPC Options..." and then in the "C Options" box enter "-d _MACOS -d _PPC_" and then click "Continue".
Now click "CreateMake" and this should then write a makefile you can use to build "server.lib" with. You should not get any
popup messages, if you do then retry these steps again.
Then from the menus select "Build" -> "Build...". At this point the program name should already be filled in with "server.lib",
but if not or if you come back to build it again, fill it in. Then click "OK". It should now build the library, and in the
main "Worksheet" window you should see a trace of the build with the last line ending with "Done". If the last line does not
end with "Done" then something went wrong with the build process, and you should check the rest of the trace for the reason.
This concludes building the "server.lib" file, which you should now find in the "source" folder called "server.lib.o".
The next is to build your plugin by doing the following steps.
First create a folder containing your source files for your plugin.
Then from the menus select "Directory" -> "Set Directory..." and then choose the folder with your source files.
Then from the menus select "Build" -> "Create Build Commands...".
Next enter your plugins name for the program name making sure it ends with ".p".
Next select "Shared Library" and "PowerPC Only".
Then click "Source Files..." and choose "servmain.c" from the "source" folder under the SDK installation and then click "Add".
Change the "Show" option to "All files" and choose and "server.lib.o" and then click "Add".
Change the "Show" option back to "'TEXT' files only" and then choose all the source files (.c and .cp, not .h) for your plugin,
and then click "Add" then "Done".
Then click "Include Search Paths..." and choose the "include" folder under the SDK installation and then click "Add" then
"Done".
At this point you may need to click "Additional Libraries..." and choose any other libraries you require (for my plugins I
did not need anything extra).
Then click "PowerPC Options..." and then in the "C Options" box enter "-d _MACOS -d _PPC_" and if you have C++ source in the
"C++ Options" box enter "-d _MACOS -d _PPC -bool on". This sets the right definitions and also enables the use of the "bool"
keyword in C++ code. Then click "Continue".
You must disable both the entry/startup and exit/shutdown points of the shared library otherwise it will fail to load in Lightwave.
In the "Link Options" box enter "-init none -term none" and then click "Continue".
Then click on "Exported Symbols..." and enter "_mod_descrip" then click "Continue".
Now click "CreateMake" and this should then write a makefile you can use to build your plugin with. You should not get any
popup messages, if you do then retry these steps again.
Then from the menus select "Build" -> "Build...". At this point the program name should already be filled in with your plugins
name, but if not or if you come back to build it again, fill it in. Then click "OK". It should now build your plugin, and
in the main "Worksheet" window you should see a trace of the build with the last line ending with "Done". If the last line
does not end with "Done" then something went wrong with the build process, and you should check the rest of the trace for
the reason. You may want to check the trace anyway for possible problems regarding warnings etc.
This concludes building your plugin file, which you should now find in the folder you created for it.
Notes - Some other hints you might find useful:
If whilst trying to open a file or building a project, MPW complains that a file is not a "TEXT" file, this is because its
not recognising the file type as TEXT based on Mac OS9 mechanism which does not use file extensions. To correct this you should
modify the files file-to-application type code to "TEXT" using an appropriate tool, like "A Better Finder Creators & Types".
In my case I had FTPed the files across, but set the mode to binary which caused their type not to be set as "TEXT". A workaround
to this was to rename the files to ".txt" before FTPing them.
Any C++ source files should have a ".cp" extension to identify them as such for MrC.
If like me you chose to build your plugin in C++ and happen to put your Startup, Shutdown and activation functions in a C++
source file. Then you will need to make sure you have put certain pieces in extern "C" blocks. I found that on Windows I could put the whole file in one and it was fine. However on the Mac with MrC i had to make
sure that only the Startup and Shutdown functions were, otherwise it failed to load properly in Lightwave. In the end my source
file ended up with Startup and Shutdown in an extern "C" block and Windows had to have it around the ServerDesc structure for it to work.