Examples: Commands to Link a PL/I Subroutine with Self-initializing RTS

32-bit Linux/UNIX

cob -z -o FMAIN1.so FMAIN1.o -e FMAIN1 -d FSUB1 
$COBDIR/lib/32/dllmain_cob.o $COBDIR/lib/32/noofm.o 
$COBDIR/lib -lmfpliz -lmfpdfpz -lrt 
$COBDIR/lib/plidump.so

64-bit Linux/UNIX

cob -z -o FMAIN1.so FMAIN1.o -e FMAIN1 -d FSUB1 
$COBDIR/lib/64/dllmain_cob.o $COBDIR/lib/64/noofm.o 
$COBDIR/lib -lmfpliz64 -lmfpdfpz -lrt 
$COBDIR/lib/plidump64.so

Windows DLLMain Source Code

#define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
#include <windows.h>

void  __lpi_init(int argc, char **argv, char **env, LANGUAGE_CODE lang);
void  __lpi_fini_and_return(LANGUAGE_CODE lang, int *pRetcode);

static short pli_lang = 0;
int argc = 0;
void * argv = NULL;
void * dummy = NULL;

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    int fini_retcode;
    char compiler_version[] = VERSION_STRING;
    int argc = 0;
    void * argv = NULL;
    void * dummy = NULL;

    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    {
        __lpi_init(argc, &argv, &dummy, pli_lang);
        P$SETUPDEFFILES();  /* establish SYSPRINT, SYSIN, SYSOUT in the RTS  */
        break;
    }
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
        break;
    case DLL_PROCESS_DETACH:
        __lpi_fini_and_return(pli_lang, &fini_retcode);
        break;
    }
    return TRUE;
}