Menu

How to call a C dynamic Library

2025-04-26
2025-04-27
  • Maurizio Bongini

    Hi
    i need to call a C Dynamic Library .. passing it a string and the libary returns another string
    in C Language is enough to add to caller the entry point of called

    extern char* DLL_Licence(char* exe);
    

    the called executable name is
    lic.so ... (lic.so source has not a main)
    then i tell the linker to reference lic.so
    How to proceed is the caller is a Cobol pgm ?
    is the procedure the same of calling a dynamic cobol library ?
    How can i pass the entry point ?
    Thanks is advance for your support
    MAurizio

     
    • Simon Sobisch

      Simon Sobisch - 2025-04-26

      The approach is similar. In any case you pass something by reference and use RETURNING ADDRESS OF LINKAGE-DATA-ITEM or a pointer, then manually setting a var's address. Like in C you need to have C pass either a pointer to a static address or allocate and therefore later deallocate the address.

      You either use CALL STATIC funcname and then pass lic.so as "input" to cobc or use COB_PRE_LOAD to use dynamic linking with different name so/func.

       
  • Maurizio Bongini

    Hi Simon
    I was able to work succesfully with both CALL STATIC and COB_PRE_LOAD
    Thanks for your support
    Maurizio

     

Anonymous
Anonymous

Add attachments
Cancel