Creating, using an external Function.

andrej
2025-04-18
2025-05-14
  • andrej - 2025-04-18

    Hello all,
    I would like to create a simple which runs directly on Control WinV3 x64 3.5.21.0

    For this purpose I created a simple dll myAdder.dll in Cpp

    // MyAdder.cpp
    // cl /LD /EHsc MyAdder.cpp /Fe:MyAdder.dll
    #include <windows.h>
    extern "C" __declspec(dllexport) int __cdecl CmpMyAdder_Add(int a, int b)
    {
        return a + b;
    }
    

    I added the dll in the respective folder. Furthermore I "registred" the dll in the CODESYSControl.cfg. However, when I want to use the library I get the error message: Uresolved reference: *'CMPMYADDERADD' *

    Can you give me a hint what step I missed or where I need to declare the dll, such that the dll resp. the reference can be resolved.

    Many thanks and kind regards

     

    Last edit: andrej 2025-04-18
  • eschwellinger

    eschwellinger - 2025-04-19

    you need the check the plclog if the the component have been loaded on startup of th plc.

     

    Last edit: eschwellinger 2025-04-19
  • andrej - 2025-04-23

    Hello,
    many thanks for your reply. I checked the logs. It seems that dll is not loaded. However other dll such as the Webserver are loaded. Could you tell me what I need to do such that my dll is loaded.
    (Furthermore I changed the C-Function a bit. I used the M4.exe from the SDK.)

    Many thanks.

     

    Last edit: andrej 2025-04-23
  • andrej - 2025-04-29

    One step closer

    Hello
    finally the SoftPlc starts to load the dll on start up, however it is not successfull.

    I create a new minimal example Lib_XMATH.dll.
    Could please give me a hint, why the dll is not succesully loaded yet. Inputs would be highly appreciated.

    Many thanks.

     

    Last edit: andrej 2025-04-30
  • andrej - 2025-05-05

    Hello all,
    could you tell me whether I need an additional license in order for v3x64 to execute the DLL?

    Is there some manual on how to proceed? Other than the rather generic message loading Component failed Lib_XMATH.dll I have no further hints.

    Many thanks for your feed back.

    PS: I tried a similar experiment (i.e. generating a native dll for windows and having it executed by the Python VM this worked without an issue).

     

    Last edit: andrej 2025-05-05

Log in to post a comment.