LoginSignup
9

More than 5 years have passed since last update.

mac OS HighSierraでのCOBOL環境構築

Last updated at Posted at 2018-05-08

about

ナウい環境でのCOBOOL環境の構築について。
会社の研修でCOBOLに触れたら意外と面白かったから書く。

どのCOBOLを入れたらいいの?

brew search cobolをしたらたくさん出て来る

$ brew search cobol
==> Searching local taps...
gnu-cobol                                open-cobol
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...

GnuCOBOLのHPを見てみるとコウ書いてあるから、GnuCOBOLを入れたらいいだろう。

GnuCOBOL (formerly OpenCOBOL) is a free COBOL compiler

導入

私の環境ではチョー簡単だった
$ brew install gnu-cobol
一発

$ cobc -V
cobc (GnuCOBOL) 2.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
Built     Feb 27 2018 09:40:48
Packaged  Sep 06 2017 18:48:43 UTC
C version "4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)"

動作確認

動作確認のために、hello worldする

hello.cob
       identification division.
       program-id. hello.

       environment division.

       data division.

       procedure division.

       hello.
        display "HELLO"
        stop run.

TIPS
COBOLプログラムは最終行が空行であることを求められるため、最終行を空行のEOFにしないと以下のようなエラーが出るから注意。

hello.cob: 12: warning: line not terminated by a newline

ほんでもってコンパイル

$ cobc -x -Wall -debug hello.cob
$ ./hello
HELLO

めでたしめでたし、いえ〜〜〜い

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9