Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Having issues with LoadDll and c4d_main

    Cinema 4D SDK
    c++ r20
    4
    5
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      victor
      last edited by victor

      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?

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        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

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • M
          mp5gosu
          last edited by mp5gosu

          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.

          1 Reply Last reply Reply Quote 0
          • kbarK
            kbar
            last edited by kbar

            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.

            https://www.gamelogicdesign.com
            https://www.plugins4d.com

            1 Reply Last reply Reply Quote 0
            • V
              victor
              last edited by

              In our case it was a bit more complex but we managed to bypass the issue using load delay dlls.

              Thank you all!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post