Open PL/I can be used to create shareable libraries (also known as shared libraries) on any supported operating system.
To produce code that can be included in a shareable library, you must ask Open PL/I to produce position-independent code by using the -pic option. Once you have object files generated as position-independent code, you link them into a shareable library using the -so option to ldpli or mfplx.
File lib1.pli:
library_one: proc; display('This is library routine one'); end;
File lib2.pli:
library_two: proc; display('This is library routine two'); end;
File myprog.pli:
dcl library_one entry; dcl library_two entry; foo: proc options(main); call library_one; call library_two; end;
Compile and link using commands:
mfplx –pic –so –omylib.so lib1.pli lib2.pli mfplx –omyprog myprog.pli mylib.so
File myfetch.pli:
myfetch: proc external(‘myfetch’); display(‘Inside fetchable function’); end;
File myprog.pli:
dcl myfetch entry options(fetchable) external(‘myfetch’); foo: proc options(main); call myfetch; end;
Compile and link using commands:
mfplx –pic –so –omyfetch.so myfetch.pli mfplx –omyprog myprog.pli