The directory in which these examples are stored is not writable by ordinary users. To compile a .erl file, the compiler must be able to write the compiled .beam file.
One way: copy files to a directory in which you can write, and compile them there:
$ mkdir erlex $ cd erlex $ cp /usr/lib/erlang/lib/gs-1.5.11/examples/src/* . $ erlc *.erl
For this, you will need the erlang-dev package, which will work.
You can run the ball example as follows:
$ erl -s ball
ball is the name of the module, and the Erlang emulator by default calls the start/0 function in this module, which in this case is correct.
However, you do not need to collect these examples. The Ubuntu erlang-examples package comes with pre-compiled ones:
$ cd /usr/lib/erlang/lib/gs-1.5.11/examples/ebin $ erl -s ball
After closing the GUI window in each, say q(). to exit the emulator. This may seem strange to you until you realize that everything about Erlang is designed for long periods of time. The fact that the last process that started the emulator has stopped is not sufficient reason for the BEAM emulator to close. In the end, something else can be run in the same emulator.
source share