0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UbuntuでCOBOLを始める

Posted at

GnuCOBOLというフリーのコンパイラを使ってLinuxでもCOBOLが使えます。

GnuCOBOLのインストール

aptでインストールします。

$ sudo apt update
$ sudo apt install gnucobol

インストールできたか確認しましょう。

$ cobc --version
cobc (GnuCOBOL) 3.1.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://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     Apr 14 2024 07:59:15
Packaged  Dec 23 2020 12:04:58 UTC
C version "13.2.0"
$ which cobc
/usr/bin/cobc

VSCodeの拡張機能を入れる

「COBOL」と検索し、以下の拡張機能を入れるとシンタックスハイライトされたり、カラム位置の縦線が入ったりします。
image.png

Hello World

HELLO.cblという名前のファイルに以下を記入します(カラム位置に注意)。

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO.
       PROCEDURE DIVISION.
           DISPLAY "Hello World!"
           STOP RUN.
       END PROGRAM HELLO.

コンパイルと連係編集を以下のコマンドで行います。

$ cobc -x ./HELLO.cbl

すると実行可能ファイルHELLOができるのでこれを実行します。

$ ./HELLO
Hello World!
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?