Specify additional directories for DLL dependencies



  • Hi!
    My plugin depends on a 3rd party external library in the form of a DLL. According to the docs, additional DLLs needed by a plugin can be placed in myplugin\res\libs\win64. (https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_maxonapi_dev_windows.html#page_maxonapi_dev_windows_practice_dll).

    For my plugin, this is not a very convenient solution. The DLL in question is already installed in a specific location, which is added to the PATH environment variable by the installer of the 3rd party library. Also, my plugin project actually consists of several c4d plugins which each need to communicate with the same copy of the DLL. My workaround solution for now is to simply place the DLL in the same directory as the c4d executable. This works, but is not very elegant.

    So: Is there any way to specify a custom directory where my plugins will look for additional dynamic libraries? This was possible in previous versions of c4d (using the standard PATH environment variable) so I am really hoping it is possible in R20 as well.

    Thanks
    /Filip



  • Hi FilipM, thanks for reaching out us.

    With regard to your request, unfortunately there are no official options than the recommendation you've already found in the documentation.
    The idea of having the dynamic library being contained in a folder under the plugin itself was actually driven by the need to grant plugins to be installed everywhere also by non-elevated users. This approach should grant plugins to access the dynamic libraries they were supposed to load without hassles.

    Although on Linux-derived OS there's still the chance to use the rpath mechanism to refer to an environment variable defining where dynamic libraries should be searched, on Windows this is not possible.

    Finally with regard to your plugin project (let's call it MyPluginProject) where multiple Cinema 4D plugins (MyPlugin01, MyPlugin02, MyPlugin0x) are accessing the same libraries, rather to go for

    <c4d>
      |-plugins
          |-MyPlugin01
              |-MyPlugin01.xdl64
          |-MyPlugin02
              |-MyPlugin02.xdl64
    ...
    ...
          |-MyPlugin0x
              |-MyPlugin0x.xdl64
    

    to consider something like

    <c4d>
      |-plugins
          |-MyPluginProject
          |-MyPlugin01.xdl64
          |-MyPlugin02.xdl64
    ...
    ...
          |-MyPlugin0x.xdl64
    

    If I end up with some workaround I'll come back here but for the time being I consider it solved.

    Best, Riccardo



  • @r_gigante said in Specify additional directories for DLL dependencies:

    If I end up with some workaround I'll come back here but for the time being I consider it solved.

    OK, thanks for the info!

    /Filip