Ubuntu下安装Erlang、rebar

Ubuntu下安装erlang、rebar

转载:https://blog.csdn.net/wd2014610/article/details/81945922

安装erlang

  1. 官网下载需要版本的安装包。
    我选择的是esl-erlang_22.0-1_ubuntu_bionic_amd64.deb
    注:从windowslinux子系统复制文件可以通过如下命令

    cp /mnt/c/download/esl-erlang_22.0-1_ubuntu_bionic_amd64.deb /home/mfile
    
  2. 通过以下命令安装:
    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
  1. 验证是否安装成功,输入erl,能够进入erlang shell即可。

安装rebar

rebar github:https://github.com/rebar/rebar

  1. 获取源码
$ git clone git://github.com/rebar/rebar.git
  1. 重新编译,获取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.
  1. 获取rebar脚本后,就可以该脚本复制到相应的工程目录下构建erlang app了。

安装rebar3

  1. 通过rebar3脚本进行安装。

    • 执行./rebar3 local install安装rebar3
    • 安装后,可通过rebar3 local upgrade进行更新。

    注意,在windows下,需要先创建rebar3.cmd,内容如下:

    @echo off
    setlocal
    set rebarscript=%~f0
    escript.exe "%rebarscript:.cmd=%" %*
    
  2. 通过从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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值