4

Creating a new plugin project in Visual Studio

The following article describes the project setup for Cinema 4D R16 and Visual Studio 2012. Updated articles on project setup can be found in the SDK documentation. Information on the Visual Studio version to use for development against a certain Cinema 4D version can be found here.

For the newbies among our fellow readers, here is a complete step by step walkthrough for creating a new plugin project in Microsoft Visual Studio. The screenshots show Visual Studio 2005, but it still works exactly the same way in Visual Studio 2010.

Basic project setup

You start with just the standard folder structure, containing a “res” folder with your symbols, icons, and string tables, and a “source” folder, containing your C++ Sources (subfolders are – of course – possible).

Take a look into the “cinema4dsdk” folder and locate the project file and the properties file.

Copy & paste these two files into your plugin’s folder.

Rename the project file as you wish, using the title of your plugin might be a good idea.

Open the project in Visual Studio

Change the project title. This will also determine the filename of the plugin binaries.

Select all of the SDK source files that are still in the project…

…and remove them by pressing the “Del” key.

Drag & drop your source files (including subfolders) into the “Source Code” in your project.

Right-click on the solution, and from the context menu choose “Add -> Existing Project…”

Now add the CINEMA 4D API project to your solution. Navigate to “CINEMA 4D/resource/_api_lib” and choose the “_api” project file.

You must also make your project dependent from the CINEMA 4D API. Right-click on your project (not on the solution) and choose “Project Dependencies…”

Make sure that “_api” is enabled.

Additional include paths

If there are any additional include directories where you have stored header files, you must add them to the project’s header search paths. Open the project settings by right-clicking on the project on top of your tree and choosing “Properties”.
Navigate to “Configuration Properties” -> “C/C++” -> “General”. Also make sure that, on top of the dialog, your have selected “All Configurations” and “All Platforms”. This will apply your changes to all build configurations for all platforms, and save you the work for applying a change to each combination separately.
Select the “Additional Include Directories” and click the little “…” icon on the right side. A dialog will pop up. You can add any path here, absolute ones as well as paths relative to your project location.

From the File menu, choose “Save All”.

The Save dialog will come up, asking you to save the solution. By default, the suggested location will be the one of your project file, and the filename will also be the one of your project file. There is no reason to change that.

That was already it, you’re done.
Start a full rebuild and see if your code compiles fine.

Setting up a debug session

Even if your project compiles fine, there might still be bugs which you’ll have to address. To do that, you will want to start a debug session with CINEMA 4D.
To set up your project for a debug session, open the project properties again and locate the entry “Debugging” in the tree on the left side. On the right side, in the “Command” entry, click the little “…” icon and select the CINEMA 4D.exe.
Note: As long as you don’t experience any issues that only occur in a 64 Bit build, you will want to use the 32 Bit build for debugging. That is, because Visual Studio only supports the “Edit and Continue” (pausing the execution, changing your code, and then continuing execution) functionality for 32 Bit. With a 64 Bit build, you will always have to stop execution, then build your project again, and then restart CINEMA 4D.

To start a debug session, click the “Play” button in the toolbar, or press F5.

Avatar

Frank Willeke

worked with computers since more than 20 years | got hooked on computer graphics back on the AMIGA | started programming at the age of 13 | relesed some successful plugins for cinema 4d | started working for maxon computer gmbh in 2009 | now contributing to cinema 4d as a senior developer making electronic music since 1993 | playing the electric guitar since 1995 age of 14 | first live gigs in 1997 | playing the bass guitar 2005 | playing keyboards and synths since 2012 experimenting with photography since 2003

4 Comments

  1. thanks alot for your efforts in these wonderful tutorials 🙂
    just one main question :
    i tried to work in debug mode so i see where are the pitfalls of my plugin …
    the problem is in cinema4d console…2nd line ..DEBUGGER NOT PRESENT

    what should i do to let it debug correct…i’m using 64 bit win8 (win 7 compiler)

  2. Did you just create a Debug build, or did you also run CINEMA 4D from Visual Studio?
    I have updated the article, please refresh your browser. There now is an extra chapter about how to set up a debug session.

  3. well thank you for the reply…

    note : (my windows got crashed…re installed…so cinema4d pathes are not in the system pathes)

    now the problem is when i debug in 64 bit ..it says need a 64 bit visual studio version !!….if i debug in 32 bit …this message appears
    (Debugging information for ‘cinema4d.exe’ can not be found or does not match . can not find or open the PDB file .

  4. For development, it doesn’t really matter where your CINEMA 4D is, as long as you have full write permissions to those folders.

    Maybe you only have a 32 Bit VisualStudio version? I recommend using Visual Studio 2005 for R13 and 2010 for R14. At least the Standard version, ideally the Professional version.

    The message that is can’t find the debugging information for CINEMA 4D.exe is normal. You only have debug symbols for you own project, now for the Cinema binary. Those symbols only Maxon has for their own debugging work. That’s normal and should not disturb you.

Comments are closed.