Building Plug-ins

From The Foundry MODO SDK wiki
Revision as of 19:06, 4 November 2012 by Philstopford (Talk | contribs) (How do I create a new Visual Studio project for a modo plugin?)

Jump to: navigation, search

The easiest way to see how to setup the project files is to start with the sample plugins. There are both Xcode and Visual Studio projects included.

How do I create a new XCode project for a modo plugin?

Firstly, you don't want to be creating a bundle, you want to create a C/C++ Library, set the type to Dynamic.

Then add a new target to the project, of the same type, but this one is a static library. Add the .cpp files in the SDK common directory to this target and set the header search path to look in the SDK header directory.

Then select your plugin target and go to build phases, add the SDK target as a target dependency. Also add the SDK target under Link Binary with libraries.

That should be everything you need to do.

How do I create a new Visual Studio project for a modo plugin?

These instructions are based on Visual Studio Express 2010 running on Windows XP 32-bit. For 64-bit the relevant project type will need to be chosen, but otherwise all steps will be equivalent. Much like the XCode instructions above, the basic idea is to create a static library project for the common.lib and set that as a dependency for your main plugin project. Let's see how this works in practice.

modo plugins are regular DLL files, easily created using the standard 'new project' wizard. You can create the plugin project before or after the common project.

Start the new project wizard. Find the template for a new DLL, and create a blank project. The project should have the name of the plugin that you want to create (e.g. test for test.dll).

Build Visual Studio2010Express step 1.png Build Visual Studio2010Express step 2.png

Now, let's get the common static library sorted out. If you already have a other modo plugin source code around, you'll likely have a common project in place. You can add it to this new project easily by simplying adding the common project as shown below :

Build Visual Studio2010Express step 3.png

Otherwise, let's create a new common project. This is done easily :

Build Visual Studio2010Express step 3 new.png

Just as before, choose the relevant project type

Build Visual Studio2010Express step 4.png

However, instead of choosing 'DLL', you need to choose the static library option. I also deselected precompiled header, but that may not be required :

Build Visual Studio2010Express step 5.png

At this point, you'll now have a single solution with two projects - the plugin and the common project.

Build Visual Studio2010Express step 6.png

We now need to ensure that the common library is built before the plugin, by making the plugin project dependent on the common library. You do this through the project dependencies menu for the plugin project.

Build Visual Studio2010Express step 7.png Build Visual Studio2010Express step 8.png

Now we need to add the source files to the common project. These are all included in the 'common' folder within modo's SDK. These files are easily added to the common project.

Build Visual Studio2010Express step 9.png Build Visual Studio2010Express step 10.png

In order for the common library to build, we also need to make sure it can find the SDK itself. To do this, we need to add modo SDK's include folder to the project. This is achieved with the following steps. Note that the images below are for the default debug build configuration. You'll need to take these steps to get the release build configuration working as well.

Build Visual Studio2010Express step 11.png Build Visual Studio2010Express step 12.png

If everything has been done correctly, you'll be able to successfully build the common library using the build option below.

Build Visual Studio2010Express step 13.png

Next we return to our plugin project. We need to take some steps to reference the common library, and also to add the modo SDK 'include' folder in the same way that we did for the common project.

Build Visual Studio2010Express step 14.png

Normally, you'd expect to find the library generated within the common project's hierarchy, but as we have it configured as a dependency for our plugin project, the library is generated within that plugin project:

Build Visual Studio2010Express step 15.png

Finally, we need to make the linker aware of the library file that contains the exported symbols that the plugin needs in order to build successfully. This is done by adding 'common.lib' to the 'Additional Dependencies' field of the Linker input settings, as below.

Build Visual Studio2010Express step 16.png