How to install Erlang on FreeBSD 13

Erlang is a functional, general-purpose, concurrent programming language and garbage-collected runtime environment built for concurrency, fault tolerance, and distributed application architectures. It is supported and maintained by Ericsson OTP product unit.

In this guide, we will install Erlang/OTP in a FreeBSD 13.

Prerequisites

You need the following to follow along

  • Updated FreeBSD Server
  • Root access or user with root access
  • Internet access from the server

Table of Content

  1. Updating the system
  2. Installing Erlang
  3. Creating Hello world program

1. Updating the system

Let us ensure that our server packages are up to date using this command:

pkg update
pkg upgrade

Let us also install some common packages

pkg install -y vim

2. Installing Erlang

The erlang package is found on the default FreeBSD repos. Install it using this command:

pkg install -y erlang

This is the output on my server

# pkg install erlang
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	erlang: 24.1.1,4
	erlang-man: 24.1

Number of packages to be installed: 2

The process will require 97 MiB more space.
36 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/2] Fetching erlang-24.1.1,4.pkg: 100%   35 MiB  36.8MB/s    00:01
[2/2] Fetching erlang-man-24.1.pkg: 100%    1 MiB   1.2MB/s    00:01
Checking integrity... done (0 conflicting)
[1/2] Installing erlang-man-24.1...
[1/2] Extracting erlang-man-24.1: 100%
[2/2] Installing erlang-24.1.1,4...
[2/2] Extracting erlang-24.1.1,4: 100%
=====
Message from erlang-24.1.1,4:

--
Installation tips:

You can find an emacs mode for Erlang here:

    /usr/local/lib/erlang/lib/tools-3.5.1/emacs

You should now have erlang installed.

3. Creating Hello world program

Create hello.erl file

vim hello.erl

Add this to the file

% This is a test Hello World Erlang Code
-module(hello).
-import(io,[fwrite/1]).
-export([helloworld/0]).

helloworld() ->
   fwrite("Hello from Citizix, Erlang World!\n").

Compile it from the Erlang shell. Don’t forget the full-stop (“period“) at the end of each command:

# erl
Erlang/OTP 24 [erts-12.1.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit] [dtrace]

Eshell V12.1.1  (abort with ^G)
1> c(hello).
{ok,hello}
2> hello:helloworld().
Hello from Citizix, Erlang World!
ok
3>

You have successfully installed Erlang in your system.

Conclusion

Thanks for using this tutorial for installing the Erlang programming language on your FreeBSD system. For additional help or useful information, we recommend you to check the official Erlang website.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy