Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Please excuse me if this is breaking any age limit rules on Stackoverflow;</p> <p>See <a href="http://opencobol.add1tocobol.com/#how-does-the-opencobol-compiler-work" rel="nofollow">http://opencobol.add1tocobol.com/#how-does-the-opencobol-compiler-work</a></p> <p>and maybe <a href="http://opencobol.add1tocobol.com/#does-opencobol-support-any-sql-databases" rel="nofollow">http://opencobol.add1tocobol.com/#does-opencobol-support-any-sql-databases</a></p> <p>for a sample of linking to database libraries.</p> <p><strong>Edit: As suggested by mbinette, instead of simple links</strong></p> <p>In short, OpenCOBOL is a multi phase compiler.</p> <ul> <li>Preprocess the source text. <strong>cobc -E</strong> to generate post processed text to stdout and stop</li> <li>Translate to C. <strong>cobc -C</strong> to generate .c source code files and stop </li> <li>Translate to assembler using native C compiler. <strong>cobc -S</strong> to generate .s assembler source and stop</li> <li>Generate object. <strong>cobc -c</strong> will generate .o object files and stop</li> <li>Build. <strong>cobc -x</strong>, or <strong>cobc -m</strong>, or <strong>cobc -b</strong> for executable, module (.so or DLL), and finally build for creating dynamic shared objects out of multiple command line inputs.</li> </ul> <p>OpenCOBOL excels at shared libraries and by using the C Application Binary Interface, can dynamically load most if not all .so (or DLL) symbols using the COBOL <strong>CALL</strong> verb.</p> <pre><code>CALL "DB2-CONNECT" USING BY REFERENCE "database name" BY CONTENT credentials BY VALUE control-bits RETURNING pointer-to-handle ON EXCEPTION DISPLAY "Can't find DB2-CONNECT, use -ldb2 with cobc" END-DISPLAY END-CALL </code></pre> <p><em>I made up the above call frame, as I don't have a DB2 library or the docs at hand</em>.</p> <p>To compile a program to use DB2 services you'd use something like</p> <pre><code>cobc -x myprogram.cob -ldb2 -L/path/to/DB2lib </code></pre> <p>or, more likely in a larger application, something along the lines of</p> <pre><code>cobc -b myprogram.cob hisprogram.cob herprogram.cob export COB_LIBRARY_PATH=/path/to/development/libraries export COB_PRE_LOAD=db2-dev:other-dev-libs cobcrun myprogram </code></pre> <p>For more details, see the FAQ, <em>hopefully forever stashed at the links above</em>.</p> <p>Pointing out that <strong>OpenCOBOL as of 1.1 does NOT support EXEC syntax</strong>. DB2 EXEC preprocessors may or may not generate COBOL suitable for OpenCOBOL. <em>I've been told the Oracle Pro*COBOL EXEC END-EXEC precompiler generates COBOL source code that compiles with OpenCOBOL for linking to Oracle SQL.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload