How to Install OpenCOBOL in OS X 10.9

I tried to install the OpenCOBOL, the open source COBOL compiler, in OS X 10.9. This is the note of it. The original site installation is old, no additional package compiles and installations are required. Just do the MacPorts installation commands only. All required packages are ready in MacPorts repository for OpenCOBOL.

1. Install MacPorts

Install MacPorts normally from here.

http://www.macports.org

2. Install OpenCOBOL from MacPorts repository


$ sudo port install open-cobol
---> Computing dependencies for open-cobol
---> Dependencies to be installed: db44 gettext expat libiconv ncurses libgnugetopt libtool mpfr
---> Fetching archive for db44
---> Attempting to fetch db44-4.4.20_2.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/db44
---> Attempting to fetch db44-4.4.20_2.darwin_13.x86_64.tbz2.rmd160 from http://jog.id.packages.macports.org/macports/packages/db44
---> Installing db44 @4.4.20_2
---> Activating db44 @4.4.20_2
---> Cleaning db44
---> Fetching archive for expat
---> Attempting to fetch expat-2.1.0_0.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/expat
---> Attempting to fetch expat-2.1.0_0.darwin_13.x86_64.tbz2.rmd160 from http://jog.id.packages.macports.org/macports/packages/expat
---> Installing expat @2.1.0_0
---> Activating expat @2.1.0_0
---> Cleaning expat
---> Fetching archive for libiconv
---> Attempting to fetch libiconv-1.14_0.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/libiconv
---> Attempting to fetch libiconv-1.14_0.darwin_13.x86_64.tbz2.rmd160 from http://jog.id.packages.macports.org/macports/packages/libiconv
---> Installing libiconv @1.14_0
---> Activating libiconv @1.14_0
---> Cleaning libiconv
---> Fetching archive for ncurses
---> Attempting to fetch ncurses-5.9_2.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/ncurses
---> Attempting to fetch ncurses-5.9_2.darwin_13.x86_64.tbz2.rmd160 from http://jog.id.packages.macports.org/macports/packages/ncurses
---> Installing ncurses @5.9_2
---> Activating ncurses @5.9_2
---> Cleaning ncurses
---> Fetching archive for gettext
---> Attempting to fetch gettext-0.18.3.2_0.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/gettext
---> Attempting to fetch gettext-0.18.3.2_0.darwin_13.x86_64.tbz2.rmd160 from http://jog.id.packages.macports.org/macports/packages/gettext
---> Installing gettext @0.18.3.2_0
---> Activating gettext @0.18.3.2_0
---> Cleaning gettext
---> Fetching archive for libgnugetopt
---> Attempting to fetch libgnugetopt-1.3_0.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/libgnugetopt
---> Attempting to fetch libgnugetopt-1.3_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/libgnugetopt
---> Attempting to fetch libgnugetopt-1.3_0.darwin_13.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/libgnugetopt
---> Fetching distfiles for libgnugetopt
---> Attempting to fetch libgnugetopt-1.3.tar.bz2 from http://cjj.kr.distfiles.macports.org/libgnugetopt
---> Verifying checksums for libgnugetopt
---> Extracting libgnugetopt
---> Configuring libgnugetopt
---> Building libgnugetopt
---> Staging libgnugetopt into destroot
---> Installing libgnugetopt @1.3_0
---> Activating libgnugetopt @1.3_0
---> Cleaning libgnugetopt
---> Fetching archive for libtool
---> Attempting to fetch libtool-2.4.2_3.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/libtool
---> Attempting to fetch libtool-2.4.2_3.darwin_13.x86_64.tbz2.rmd160 from http://jog.id.packages.macports.org/macports/packages/libtool
---> Installing libtool @2.4.2_3
---> Activating libtool @2.4.2_3
---> Cleaning libtool
---> Fetching archive for mpfr
---> Attempting to fetch mpfr-3.1.1-p2_0.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/mpfr
---> Attempting to fetch mpfr-3.1.1-p2_0.darwin_13.x86_64.tbz2.rmd160 from http://jog.id.packages.macports.org/macports/packages/mpfr
---> Installing mpfr @3.1.1-p2_0
---> Activating mpfr @3.1.1-p2_0
---> Cleaning mpfr
---> Fetching archive for open-cobol
---> Attempting to fetch open-cobol-1.1_0.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/open-cobol
---> Attempting to fetch open-cobol-1.1_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/open-cobol
---> Attempting to fetch open-cobol-1.1_0.darwin_13.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/open-cobol
---> Fetching distfiles for open-cobol
---> Attempting to fetch open-cobol-1.1.tar.gz from http://jaist.dl.sourceforge.net/open-cobol
---> Verifying checksums for open-cobol
---> Extracting open-cobol
---> Configuring open-cobol
---> Building open-cobol
---> Staging open-cobol into destroot
---> Installing open-cobol @1.1_0
---> Activating open-cobol @1.1_0
---> Cleaning open-cobol
---> Updating database of binaries: 100.0%
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.
$

3. Try Hello COBOL

Make the COBOL program as below. (from OpenCOBOL getting started page http://www.opencobol.org/modules/bwiki/index.php?cmd=read&page=UserManual%2F1)

* Sample COBOL program
IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.

Next, compile and execute.

$ cobc -x hello.cob
clang: warning: argument unused during compilation: '-R/opt/local/lib'
$ ./hello
Hello World!

Fine 😉

2 Replies to “How to Install OpenCOBOL in OS X 10.9”

  1. I tried this and got clang: error: unknown argument: ‘-R/opt/local/lib’ [-Wunused-command-line-argument-hard-error-in-future]
    clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

    1. Right, and there might be a bug including the script of compilation.
      (it also include in my sample output above. A space required between -R and directory options)

Leave a Reply