How to use erlang examples

I just downloaded Erlang using apt-get on Ubuntu 10.10 . How to run examples with Erlang (examples that you can go through apt-get install erlang-examples ). I tried to go to the directory where they were saved and compiled ball.erl , but I got this error:

 ball.bea#: error writing file error 
+4
source share
1 answer

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.

+12
source

Source: https://habr.com/ru/post/1345991/


All Articles