Compiling the Cinema 4D SDK examples

Note: applicable to R19 and earlier versions only.

Using Visual Studio to create C4D plugins

Once you start looking at the C4D SDK, you realise that while it's quite a good reference, there's very little on how to start writing a plugin - and in particular on how to set up the compiler to produce the finished plugin. After some work on this, and a lot of reading of the SDK and compiler documentation, I was able to produce a working plugin. I wrote these pages so I wouldn't forget the necessary steps in future and thought that they might be helpful, warts and all, to other aspiring plugin developers. So here they are. As far as I know they are accurate, in that at least I get a working plugin on completion.

Visual Studio version

One caveat before we start: this was originally written using a 64-bit Windows PC and Microsoft Visual Studio 2008 as the compiler. These pages will be of most use if you are using a similar system. You can use later versions up to and including VS 2019.There won't be much difference other than in some compiler options and how they are set in the VS IDE. I would recommend using the latest stable version of VS, which is 2019 at the time of writing.

If on the other hand you are developing on a Mac then these pages will still be of some use to you, but you will have to find the equivalent compiler options for Xcode or whatever development system you are using; not all will be relevant to Macs and undoubtedly Macs will have issues not relevant to a PC. If you use a Mac, see this addendum page for some hints about Xcode and the differences between C4D versions on the Mac.

Requirements

So, what do you need to get started? You require:

  1. Cinema 4D itself (for the SDK examples and, of course, to test your plugin)
  2. the Cinema 4D SDK documentation, downloadable from the Maxon Plugin Cafe - make sure you get the correct documentation for your release of C4D
  3. Microsoft Visual Studio, VS 2019 is recommended and the free Community edition is fine
  4. depending on the SDK you are using, and which versions of VS you already have installed on your machine, you may also need the Windows platform SDK downloadable from the Microsoft MSDN site

Once you have installed VS successfully, the first thing to do is compile the SDK examples. These are located in the Cinema 4D installation directory, at \plugins\cinema4dsdk. Once you compile it, you get a huge plugin with a lot of different examples that you can dissect and see how they work. It's also a great test to make sure that you are able to compile plugins at all before starting on your own.

Compiling the SDK examples: 1

Maxon implies that compiling the SDK examples is a simple matter of building the solution. The problem is that that is only the case if you are using the version of VS recommended for the SDK version you are compiling. You can find out the recommended versions on the MAXON developers site at https://developers.maxon.net/?page_id=1108. Generally speaking, don't use an earlier version of VS than the recommended one. You can use a later version, but if you do then you will almost certainly be prompted by VS to convert the solution into one suitable for that version of VS.

Firstly, load the SDK example solution into Visual Studio. The file you want is the solution file, which is located at plugins\cinema4dsdk\cinema4dsdk.sln. If you're using VS 2019, you will almost certainly see this:

Be sure to click Cancel on this box. Don't update the toolset, if you do then the plugin probably won't compile.

Once the solution is loaded, just click 'Build Solution' in the Build menu of VS. If you are lucky the solution will just build without any problems and you will end up with the 64-bit debug version of the SDK plugin wherever you built it. If you're unlucky, you may see something like this:

This happens because VS couldn't find the Windows SDK - see the requirements point 4 above - so the compiler just gave up.

On my machine I get this error if building the R16 SDK example but not if I build the R19 SDK example. The reason isn't easy to find but if I look at the project properties for the R16 SDK I see this:

The required platform toolset is not available because I never installed VS 2012 on this machine. By contrast, the properties for the R19 SDK look like this:

This is because I did have VS 2015 on this PC. So, if you get this problem, just download and install the earlier version of VS (you can see which one is required from the properties dialog box as shown above). You can't download the toolset separately, unfortunately. Then quit VS 2019 and relaunch it and everything should work.

To build your own plugin you can copy the entire cinema4dsdk directory, rename it, delete what you don't want from the cinema4dsdk project and modify what's left.

Compiling the SDK on a Mac

Things are a bit different on the Mac, so I have added a separate addendum page to cover the use of Xcode in compiling the SDK examples.

Back to main tutorials page

Page last updated June 23rd 2021