Ubuntu下安装erlang、rebar
转载:https://blog.csdn.net/wd2014610/article/details/81945922
安装erlang
-
在官网下载需要版本的安装包。
我选择的是esl-erlang_22.0-1_ubuntu_bionic_amd64.deb
。
注:从windows
向linux
子系统复制文件可以通过如下命令cp /mnt/c/download/esl-erlang_22.0-1_ubuntu_bionic_amd64.deb /home/mfile
-
通过以下命令安装:
dpkg -i esl-erlang_22.0-1_ubuntu_bionic_amd64.deb
然后,会提示缺少依赖,大概是这个样子的:
Selecting previously unselected package esl-erlang.
(Reading database ... 60202 files and directories currently installed.)
Preparing to unpack esl-erlang_22.0-1_ubuntu_bionic_amd64.deb ...
Unpacking esl-erlang (1:22.0) ...
dpkg: dependency problems prevent configuration of esl-erlang:
esl-erlang depends on libwxbase2.8-0 | libwxbase3.0-0 | libwxbase3.0-0v5; however:
Package libwxbase2.8-0 is not installed.
Package libwxbase3.0-0 is not installed.
Package libwxbase3.0-0v5 is not installed.
esl-erlang depends on libwxgtk2.8-0 | libwxgtk3.0-0 | libwxgtk3.0-0v5; however:
Package libwxgtk2.8-0 is not installed.
Package libwxgtk3.0-0 is not installed.
Package libwxgtk3.0-0v5 is not installed.
esl-erlang depends on libsctp1; however:
Package libsctp1 is not installed.
dpkg: error processing package esl-erlang (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
esl-erlang
安装相应的依赖:
apt-get install libwxbase3.0-0v5
安装后可能会提示:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
esl-erlang : Depends: libwxgtk2.8-0 but it is not installable or
libwxgtk3.0-0 but it is not installable or
libwxgtk3.0-0v5 but it is not going to be installed
Depends: libsctp1 but it is not going to be installed
Recommends: erlang-mode but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
此时输入apt-get -f install
即可。
我自己在安装依赖后出现的提示是让我执行apt --fix-broken install
,跟着执行之后也可以了。
安装完依赖后,再次执行即可:
dpkg -i esl-erlang_22.0-1_ubuntu_bionic_amd64.deb
- 验证是否安装成功,输入
erl
,能够进入erlang shell
即可。
安装rebar
rebar github:https://github.com/rebar/rebar
- 获取源码
$ git clone git://github.com/rebar/rebar.git
- 重新编译,获取
rebar
脚本
$ cd rebar
$ ./bootstrap
Recompile: src/getopt
...
Recompile: src/rebar_utils
==> rebar (compile)
Congratulations! You now have a self-contained script called "rebar" in
your current working directory. Place this script anywhere in your path
and you can use rebar to build OTP-compliant apps.
- 获取
rebar
脚本后,就可以该脚本复制到相应的工程目录下构建erlang app
了。
安装rebar3
-
通过
rebar3
脚本进行安装。- 执行
./rebar3 local install
安装rebar3
。 - 安装后,可通过
rebar3 local upgrade
进行更新。
注意,在
windows
下,需要先创建rebar3.cmd
,内容如下:@echo off setlocal set rebarscript=%~f0 escript.exe "%rebarscript:.cmd=%" %*
- 执行
-
通过从
git
下载源代码进行安装。执行以下命令:git clone https://github.com/erlang/rebar3.git$ cd rebar3$ ./bootstrap
上述命令会在当前目录下创建一个
rebar3
脚本,后续可通过如下命令进行全局安装:$ ./rebar3 local install
使用rebar3
创建项目
$ rebar3 new app ProjectName
使用rebar3 compile
命令会添加依赖和编译整个项目。
$ rebar3 shell
此命令在shell
中运行项目,且会包含项目的ebin
以及所有依赖的ebin
。