Having issues with LoadDll and c4d_main



  • We have a plugin that has lots of third party dependencies like Qt and others.

    In the past (R19 and older versions) we had a loader plugin that loads all this third party dependencies and makes a hook by defining c4d_main(LONG action, void* p1, void* p2, void* p3) and calling c4d_main(LONG action, void* p1, void* p2, void* p3) in other dll we it did by using GetProcAddress(hModule, "c4d_main");

    It worked like a charm until r20. With the introduction of the new project scheme and the autogenerated code, it seems like any calls done to the core or cinema frameworks inside the DLL we manually load just crash due to missing initialization on some of the internal maxon components.

    We've made sereval tries like skipping that GetProcAddress call and putting the .dll as other plugin in C4D but it seems that or first plugin (the one that loads the dependencies) is not making its work (we tried to load the dependencies on PluginStart and in PluginMessage) so it is not loaded (and no error message is triggered neither)

    We believe this might be because C4D is calling more routines than c4d_main since R20 on the plugins, so our method is no longer compatible unless we replicate C4D's behavior.

    Any thought on this?


  • Global Moderator

    Hello,

    just to make sure I understand: what exactly are you doing with all that c4d_main stuff?

    Do you have C4D code in the Dlls you are loading? What won't work anymore with R20. All modules using the Cinema 4D API must be loaded by the core on startup.

    Why do you load these dependencies manually?

    best wishes,
    Sebastian



  • Do you happen to develop Anima? If so, I'd like to mention that in our company, C4D frequently crashed on R19 (especially in combination with rendering in Corona). So I attached a debugger and analyzed the crash reports and found out that Anima caused these crashes - especially with that c4d_main.

    So - if you are coincidentally developing that plugin, I beg you to overthink your approach - like Sebastian said. Until then, we unfortunately had to remove that plugin due to the increased instability.



  • In R20 you can just place your dll's in your plugin res folder in the following location "res/libs/win64".

    These will then get loaded in for you when your plugin starts up.