Development for Linux

Development Environment

GNU Compiler Collection (GCC) is the compiler for compiling Cinema 4D plugins for Linux (Ubuntu and CentOS). See Development Environments for an overview of supported Linux development environments for different versions of Cinema 4D.

Plugin Suffix

The following suffixes are supposed to be used for compiled plugins:

  • Cinema 4D R20+ SDK : .xso64
  • Cinema 4D R19 SDK : .so64

Best Practice

Linux Specific Code

Linux specific code can be guarded with the macro MAXON_TARGET_LINUX:

#ifdef MAXON_TARGET_LINUX
#endif

Building Plugins for R20

Building the SDK examples provided with Cinema 4D on Linux is done through the following steps:

  1. Unzip the sdk.zip file to a location of your choice (in the following the path $HOME/C4D_SDK/SDK_20 is used).
    $ cp sdk.zip ~/C4D_SDK
    $ cd ~/C4D_SDK && unzip -d SDK_20 ./sdk.zip
  2. Choose the appropriate project tool archive and install the project tool to a location of your choice. In the following a user's local "bin" folder is used.
    • For CentOS 7:
      $ mkdir ~/bin
      $ cp cinema4d_r20_project_tool_centos7.tar.xz ~/bin
      $ cd ~/bin && tar xJvf cinema4d_r20_project_tool_centos7.tar.xz
    • For Ubuntu 14.04:
      $ mkdir ~/bin
      $ cp cinema4d_r20_project_tool_ubu1404.tar.xz ~/bin
      $ cd ~/bin && tar xJvf cinema4d_r20_project_tool_ubu1404.tar.xz
  3. Run the Project Tool to create the project files for the SCons build system. This is done by running the project tool and pointing it to the location where the sdk archive in installed.
    $ cd ~/bin/sdk_project_tool
    $ export LD_LIBRARY_PATH=$PWD/lib64 && ./kernel_app_release64 g_updateproject=~/C4D_SDK/SDK_20
  4. Build the frameworks and the plugins contained.
    $ cd ~/src/maxon_plugin_dev
    $ cd plugins/project && python link_sconscript_plugins.py && cd ../..
    $ scons -f plugins/project/SConstruct.plugins
    PyObject * src
    Definition: abstract.h:305
    PyFrameObject * f
    Definition: ceval.h:26

Building Plugins for R19

Building the SDK examples provided with Cinema 4D on Linux is done through the following steps:

  1. Create a base directory for development (in the following steps the path $HOME/C4D_SDK/SDK_19 is used).
    $ mkdir ~/C4D_SDK/SDK_19
  2. Copy the Cinema 4D frameworks and example files:
    $ cp -r /opt/maxon/cinema4d/<version>/bin/frameworks ~/C4D_SDK/SDK_19
    $ cp -r /opt/maxon/cinema4d/<version>/bin/plugins ~/C4D_SDK/SDK_19
    The maxon namespace contains all declarations of the MAXON API.
    Definition: autoweight.h:14
  3. Create a symbolic link to the frameworks
    $ cd ~/C4D_SDK/SDK_19/plugins/example.main
    $ ln -s ../../frameworks
    PyObject PyObject const char const char char ** s
    Definition: bytesobject.h:60
  4. Create a symbolic link to the main build file:
    $ cd ~/C4D_SDK/SDK_19/plugins
    $ ln -s example.main/SConstruct
  5. Start the build process
    $ scons

Compiler Remarks

The main project file "SConstruct.plugins" expects the GCC executable files to be in /usr/local/gcc/gcc/bin. Creating symbolic link to gcc and g++ is recommended rather than editing "SConstruct.plugins" To look for a specific gcc version residing in /usr/local/gcc/<gcc-version>/bin use:

$ scons -f plugins/project/SConstruct.plugins gcc_version=<gcc-version>

Running on Terminal

Cinema 4D for Linux is solely available as command-line render (c4d_clr) and is supposed to run in a terminal window without GUI. Assuming Cinema 4D is installed in /opt/maxon/cinema4d/<c4d-version>/, the command line is:

$ cd /opt/maxon/cinema4d/<c4d-version>/bin
$ . ./setup_c4d_env && ./Commandline <optional arguments>

Running Plugins

It is possible to start Cinema 4D to run and debug a plugin:

  • set the command line argument g_additionalModulePath to make sure that this Cinema 4D executable will find and load the plugin.

Additionally one can set the command line argument g_runUnitTests to automatically execute custom unit tests.

Debugging

The binary plugin build for debugging is created specifying config="debug64".

$ scons -f plugins/project/SConstruct.plugins config="debug64"

The Terminal window displays messages printed with DiagnosticOutput(). See Debug and Output Functions.

For general information on debugging see Debugging Techniques.