ArticleslgStudy

computer science

GnuCOBOL

GnuCOBOL is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand GnuCOBOL rather than just read about it. In short: GnuCOBOL (formerly known as OpenCOBOL, and briefly as GNU Cobol) is a free implementation of the COBOL programming language that is part of the GNU project. GnuCOBOL translates the COBOL code into C and then compiles it using the native C compiler.

GnuCOBOL — main illustration
GnuCOBOL — illustration

Key takeaways

  • GnuCOBOL belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect GnuCOBOL to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of GnuCOBOL from memory before moving on to harder problems.

Reference excerpt

GnuCOBOL (formerly known as OpenCOBOL, and briefly as GNU Cobol) is a free implementation of the COBOL programming language that is part of the GNU project. GnuCOBOL translates the COBOL code into C and then compiles it using the native C compiler. Originally, the project started as OpenCOBOL in 2002. It has facilities to incorporate COBOL programs with C libraries as well as other programs, plus it is compatible with a number of COBOL dialects. It has a compiler and runtime environment on several operating systems, such as Linux, BSD, macOS and Microsoft Windows.

History While collaborating with Rildo Pragana on TinyCOBOL, Keisuke Nishida initiated the development of a COBOL compiler designed for integration with GCC, which led to the creation of the OpenCOBOL project. Nishida served as the lead developer until 2005, up to version 0.31. Roger While succeeded him as the lead developer and released OpenCOBOL 1.0 on 27 December 2007. Development on the OpenCOBOL 1.1 pre-release continued until February 2009. In May 2012, active development transitioned to SourceForge, and the February 2009 pre-release was officially marked as a release. In late September 2013, OpenCOBOL was accepted as a GNU Project, renamed to GNU Cobol, and then finally to GnuCOBOL in September 2014. Ron Norman contributed a Report Writer module as a branch of GnuCobol 2.0, and Sergey Kashyrin developed a version that uses C++ intermediates instead of C. Transfer of copyrights to the Free Software Foundation over GnuCOBOL source code (including versions with GNU Cobol and OpenCOBOL spellings) was finalized on 17 June 2015. The latest current release is v3.2, which was released on 28 July 2023.

Philosophy

While aiming to adhere to COBOL standards, including the COBOL 2014 specification and features commonly found in existing compilers, the developers do not assert any formal level of standards conformance. Nevertheless, the 2.2 (released September 2017) successfully passes 9,688 out of 9,708 tests (99.79%) from the NIST test suite, with 20 tests excluded. The latest stable release, version 3.2, was released in July 2023. GnuCOBOL translates a COBOL program (source code) into a C program. The C program can then be compiled into machine-executable object code or into a library where other programs can call (link to) it. On UNIX and similar operating systems (such as Linux), the GNU C compiler is used for this process. On Windows, the C compiler provided by Microsoft's Visual Studio software package is typically used; earlier versions also supported the now-discontinued Visual Studio Express editions. Although the two-step compilation process is typically performed with a single command, an option is available to halt the process after the C code has been generated.

Documentation From 2002 until 2012, the official home of the development team was the opencobol.org website, which served as the primary source of upstream development information. However, more recent developments have shifted to a SourceForge project space under GnuCOBOL. The GnuCOBOL Programmer's Guide, by Gary Cutler, was published under the GNU Free Documentation License. It has been updated to include GnuCOBOL with Report Writer and is listed in the GnuCOBOL documentation overview page with latest versions in the code tree. It is currently maintained by Vincent Coen and others as each new compiler version is issued and is available at GnuCOBOL - GNU Project.

Example programs

Historical

Compilation and execution:

Modern, free format

Compilation and execution:

Shortest The shortest valid COBOL program, with the relaxed syntax option in GnuCOBOL 2.0, is a blank file. Compilation and execution:

For earlier versions and with relaxed syntax:

Compilation and execution:

Without relaxed syntax and with any version of GnuCOBOL, GNU Cobol or OpenCOBOL. (Note, there are 7 leading spaces to conform to FIXED layout COBOL source):

Compilation occurs without errors:

Please note that these trivia listings are not to be regarded as good COBOL form; COBOL was designed to be a readable English programming language.

Implementation The parser and lexical scanner use Bison and Flex. The GPL licensed compiler and LGPL licensed run-time libraries are written in C and use the C ABI for external program linkage. Build packaging uses the GNU Build System. Standard tests with make check use Autoconf, ANSI85 testsuite run by make test use Perl scripts. The configure script that sets up the GnuCOBOL compile has options that include:

choice of C compiler and its options for post translation compilation database management system for ISAM support inclusion of iconv

Availability 1.0 release from SourceForge. 1.1 release from SourceForge 2.0 development release from SourceForge open-cobol Debian package. 2.2 Final, released 7 September 2017 from SourceForge 2.2 Documentation, released September 2017 from the SourceForge Code Tree. 3.1 Released July 2020 along with the documentation. 3.2 Released July 2023 along with the documentation.

References

External links GNU site, official releases of GnuCOBOL GnuCOBOL on SourceForge GnuCOBOL FAQ Open Source COBOL Consortium in Japan Add1ToCOBOL Open Source Cobol and OpenCOBOL advocacy site tiny-cobol on SourceForge

Illustrations

GnuCOBOL illustration

Worked examples

Example 1 — a first encounter with GnuCOBOL

Start with the simplest possible case. Write down what GnuCOBOL claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to GnuCOBOL before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about GnuCOBOL ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of GnuCOBOL

In research
GnuCOBOL appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses GnuCOBOL in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
GnuCOBOL is common in secondary-school and first-year university syllabi. It links to neighbouring topics COBOL, Compilers, Free and open source compilers, so understanding it makes those chapters shorter.
In everyday life
Look for GnuCOBOL outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “GnuCOBOL” →

How to study GnuCOBOL in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what GnuCOBOL means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain GnuCOBOL out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is GnuCOBOL in simple terms?

GnuCOBOL (formerly known as OpenCOBOL, and briefly as GNU Cobol) is a free implementation of the COBOL programming language that is part of the GNU project. GnuCOBOL translates the COBOL code into C and then compiles it using the native C compiler.

Why does GnuCOBOL matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study GnuCOBOL?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on GnuCOBOL.

Tags

  • COBOL
  • Compilers
  • Free and open source compilers
  • GNU Project software

Keep exploring