如何在Erlang中安装驱动程序? (特别是MySQL-otp驱动程序)

时间:2018-12-10 04:26:16

标签: mysql erlang otp erl

documentation中,此驱动程序看起来不错。我不知道如何安装它,但是我可以使用它。我读过某个地方,也许应该使用rebar?,但我看过该文档时,似乎出现了相反的问题。它说明了如何安装,但没有说明如何使用。


更新

所以看起来在安装钢筋后,我可以添加行

{deps, [
    {mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp",
                   {tag, "1.3.3"}}}
]}.

到我的文件rebar.config。我不知道这是怎么回事。我现在必须编译或制作此文件吗? rebar.config是否必须与我的项目位于同一目录中?对,不是rebar.config的路径是~/rebar/rebar.config 放置我的项目以便在文件层次结构中添加钢筋是兄弟姐妹吗?


更新

我用钢筋文件夹运行./rebar get-deps并得到

Pulling mysql from {git,"https://github.com/mysql-otp/mysql-otp",
                        {tag,"1.3.3"}}
Cloning into 'mysql'...
==> mysql (get-deps)

虽然我仍然不太清楚这是什么意思,当我尝试编译erlang文件时,我收到了结果。

c(erlangFile.erl).
{error,non_existing}

2 个答案:

答案 0 :(得分:1)

rebar是erlang的构建工具。请通过https://github.com/rebar/rebar/wiki/Rebar-commands获得命令。 获得依赖性后,需要使用“钢筋编译”来进行编译。 要使用光束文件,必须使用Add Path to Erlang Search Path?给出输出光束路径 这些方法。 然后,您将可以在代码中使用它。

答案 1 :(得分:0)

在这种情况下下载您的软件包

git clone https://github.com/mysql-otp/mysql-otp.git

下载名为rebar的工具

git clone git://github.com/rebar/rebar.git
cd rebar
./bootstrap

Add the following to rebar/rebar.config

{deps, [
    {mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp",
                   {tag, "1.3.3"}}}
]}.

在rebar / mysql-otp目录中运行

./rebar get-deps

然后在同一目录中运行

./rebar compile

这会将一堆.beam文件和.app文件放入ebin /目录

接下来将ebin /目录添加到您的路径。您可以更新$ ERL_LIBS环境变量run an include command within the erlang console like

1> code:add_pathz("~/rebar/mysql-otp/ebin").

1> code:add_pathz("rebar/mysql-otp/ebin")

And theres a few other ways to add it to your Erlang path.


还要确保还安装了mysql

这里有一些对我有用的mysql安装说明链接

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7

No package msyql-server available