Installing and getting started with Simula programming

To get started with Simula, I first setup a virtual machine running Ubuntu. From a clean install Ubuntu I needed just a couple of things installed, gcc and make.

$ sudo apt install gcc
$ sudo apt install make

Now it is time to install the Simula compiler, Cim. The instructions on their page is correct for linux at least. I did those steps and then the cim command was available for me.

$ wget http://simula67.at.ifi.uio.no/Cim/cim-3.37.tar.gz
$ tar -xf cim-3.37.tar.gz
$ cd cim-3.37
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig /usr/local/lib

Hello Simula

Writing HelloWorld in Simula is pretty simple. just starting with begin and ending with end.

begin
    Outtext("Hello, Simula!");
    Outimage;
end

I had installed the cim compiler in a virtual machine, running newest Ubuntu desktop 64-bit. The cim compiler continued failing with the same message and from what I could find out on Google and looking at the cim source code, that is because of memory and trying to access memory outside of what is available. Trying to run the compiler with cFlag for the GCC compiler to use 32-bit, did not help. What I ended up doing is switching out the Ubuntu VM with an older Ubuntu VM 32-bit version. When that was setup again in a 32-bit version of Ubuntu, it was compile time and this time it went smooth as butter 😎

cim hello.sim
Compiling hello.sim:
gcc -g -O2 -c hello.c
hello.c:105:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main(__argc,__argv)int __argc;char *__argv[];{__progname= __argv[0];goto __sw;__l0:__rstart(__argc,__argv);goto __start;__l1:__slutt:__rslutt();exit(0);__start:__curent_map=__mapmain;
 ^
hello.c: In function ‘main’:
hello.c:105:84: warning: implicit declaration of function ‘__rstart’ [-Wimplicit-function-declaration]
 main(__argc,__argv)int __argc;char *__argv[];{__progname= __argv[0];goto __sw;__l0:__rstart(__argc,__argv);goto __start;__l1:__slutt:__rslutt();exit(0);__start:__curent_map=__mapmain;
                                                                                    ^
hello.c:105:134: warning: implicit declaration of function ‘__rslutt’ [-Wimplicit-function-declaration]
 main(__argc,__argv)int __argc;char *__argv[];{__progname= __argv[0];goto __sw;__l0:__rstart(__argc,__argv);goto __start;__l1:__slutt:__rslutt();exit(0);__start:__curent_map=__mapmain;
                                                                                                                                      ^
hello.c:105:145: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
 main(__argc,__argv)int __argc;char *__argv[];{__progname= __argv[0];goto __sw;__l0:__rstart(__argc,__argv);goto __start;__l1:__slutt:__rslutt();exit(0);__start:__curent_map=__mapmain;
                                                                                                                                                 ^
hello.c:105:145: warning: incompatible implicit declaration of built-in function ‘exit’
hello.c:105:145: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
hello.sim:1:37: warning: implicit declaration of function ‘__rb’ [-Wimplicit-function-declaration]
hello.sim:3:44: warning: implicit declaration of function ‘__rbe’ [-Wimplicit-function-declaration]
hello.sim: At top level:
hello.sim:6:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
hello.sim: In function ‘__init’:
hello.sim:6:10: warning: implicit declaration of function ‘__init_FILE’ [-Wimplicit-function-declaration]
hello.sim:6:24: warning: implicit declaration of function ‘__init_SIMENVIR’ [-Wimplicit-function-declaration]
hello.sim: At top level:
hello.sim:7:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
hello.sim: In function ‘__do_for_each_stat_pointer’:
hello.sim:8:43: warning: implicit declaration of function ‘__do_for_each_pointer’ [-Wimplicit-function-declaration]
hello.sim: At top level:
hello.sim:10:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
hello.sim:13:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
gcc -g -O2 -o hello hello.o -L/usr/local/lib -lcim

Teis Lindemark

Read more posts by this author.