I am working with a colleague on a plugin that was recently ported to R20, and have encountered an issue. The plugin works fine on my colleagues machine, but when I compile it on my computer it fails to load in c4d without any warnings or errors. The plugin uses the classic API, and through testing I have concluded that "PluginStart" is never called. Here is what I did to debug this so far:
-I copied the compiled dll from my colleague, that worked on his computer.
-I placed these in a separate folder containing only our plugin and the c4d sdk plugins (built from the same solution).
-In the c4d preferences, I set this folder as the only plugin folder, so that no other plugins are loaded.
In this test, the c4d sdk plugins load fine, but our plugin does not. This is indicates to me that the plugin folder is setup correctly, and the problem actually is with our plugin. But this is the same dll that loads fine on my colleagues computer!
I realize that this is a very vague problem description, but any suggestions on what might be causing a similar issue is warmly welcome!
I assume, you are using different versions. Check, that you both use the very same SDK version that comes with any C4D installation/update.
We are both on R20, but it's quite possible that we are on different minor versions. I will check.
I have understood that from R20 and on, compiled plugins will not be compatible across releases, but I assumed that this only applied to major releases. Are you saying that compiled plugins are not even compatible between minor releases?
(As I wrote in my original post, the c4d sdk plugins work fine, it is only our plugin that does not load)
Ah, I somehow overrad that the cinema4dsdk worked.
I'm actually out of ideas here.
And yes, it cann occur that plugins compiled with higher version than the one the plugin is installed to won't work at all.
Maybe it's just the classic "Open user folder, go into subfolder "prefs" and delete file "directorycache" before starting Cinema 4D" ?
Hi FilipM, thanks for reaching out us.
With regard to the plugin not loading you should ensure that:
Looking forward further comments, give best.
Thanks a lot for the input everybody! None of these things appear to solve my problem, so I am now investigating more closely if this is something specific to our plugin code. I'll post here again if I come up with a solution.
OK; I seem to have pinpointed the problem to the use of an external library. I created a minimal example plugin that recreates the problem. Including the header file for the external library does not cause any problem, but as soon as I actually create an instance of a class defined in this header in my code, my plugin will stop loading (although everything compiles just fine).
The external library is essential to my plugin, so I can't work around this. In previous versions of c4d (pre-R20) I have used this external library a lot without problems.
Is there anything special I should look out for here? Is it possible,for example, that the source processor does anything to the headers of the external library when I include them? (My understanding of the role of the source processor is still a little shallow).
I have identified the issue: My plugin could not find/load the dll containing the implementation of the external library. If I place a copy of this dll in <myplugin>\res\libs\win64 then my plugin loads correctly in c4d and is able to call the 3rd party external library.
I found the information about where to place external libs here: https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_maxonapi_plugin_dev.html#page_maxonapi_plugin_dev_dependencies_dependencies
In the case of my plugin, however, this solution is not quite satisfactory. It is a large project consisting of several c4d plugins, each dependent on the 3rd party external library. With this solution, I would have to place a copy of the dll in each plugin folder- The dll is quite large (it's a renderer!) so this would bloat my plugin significantly.
Is there any way of telling a c4d plugin to look for dll:s in a specificed directory? (And, as a secondary question: Previously, it was enough to add the dll directory to the PATH environment variable. Is there a good reason why this behaviour was changed?)
This has deviated a bit from the original question, so I will mark this as solved and open a new thread with the remaining questions.
Thanks for the input everybody!