Skip to content

Software License Dongle for COBOL

COBOL binds by calling the core library like any other external routine, using the CALL statement with BY VALUE and BY REFERENCE as appropriate. This works on distributed COBOL — Micro Focus, GnuCOBOL and similar — where a USB device is physically reachable.

WORKING-STORAGE SECTION. COPY KEYNUB. PROCEDURE DIVISION. CALL “licdf_open” USING BY REFERENCE WS-SERIAL RETURNING KN-HANDLE IF KN-HANDLE NOT > 0 DISPLAY “No KeyNub license dongle found” MOVE 16 TO RETURN-CODE STOP RUN END-IF CALL “licdf_session_open” USING BY VALUE KN-HANDLE RETURNING KN-STATUS CALL “licdf_close” USING BY VALUE KN-HANDLE RETURNING KN-STATUS.

Where this applies, and where it does not

To be straightforward: this is for COBOL running on Windows, Linux or a Unix where a USB dongle can be attached. If your COBOL runs on z/OS, a USB device in a laptop is not the answer to your licensing question and we will not pretend otherwise.

Where it does apply, the usual situation is a vendor-supplied COBOL business application installed at customer sites, where the licensed instance count has drifted over the years and nobody can prove what it should be. A dongle per installation makes that countable again without rewriting anything.

Getting the library loaded

One deployment detail costs more time here than anything else. GnuCOBOL resolves CALL targets at run time through libcob rather than at link time, so linking the native library into the executable is not enough: name it in COB_PRE_LOAD, without its prefix or file extension, and point COB_LIBRARY_PATH at the directory holding it. Get that wrong and the failure is a module-not-found error at run time, which reads like a missing program rather than a missing library.

The binding ships as a copybook you COPY into working storage, carrying the status codes, the flag bits and the picture clauses, and is verified with GnuCOBOL 3.2.

Code

Runnable sample: cobol/verify-and-read.cbl. Binding source: bindings/cobol. Both are Apache-2.0, in the public SDK repository; the prebuilt native libraries are in the repository’s natives/ folder, one per platform.

All supported languages · All industries · Buy a KeyNub · Ask us something