代码之家  ›  专栏  ›  技术社区  ›  Sam

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

  •  0
  • Sam  · 技术社区  · 7 年前

    documentation 这个司机看起来很棒。我不知道如何安装它,这样我就可以使用它了。我在某个地方读到了我应该用的东西 rebar? 不过,我查看了该文档,它似乎有相反的问题。它说明了如何安装,但没有说明如何使用。


    更新

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

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

    到我的文件rebar.config。我不知道这是怎么回事。我必须现在编译或制作这个文件吗?rebar.config是否必须与我的项目位于同一目录中?右侧不是钢筋.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)
    

    c(erlangFile.erl).
    {error,non_existing}
    
    2 回复  |  直到 7 年前
        1
  •  1
  •   Girdhar Sojitra    7 年前

    钢筋是erlang的构建工具。请通过 https://github.com/rebar/rebar/wiki/Rebar-commands 对于命令。 获得依赖项后,需要“钢筋编译”来编译它。 要使用梁文件,必须使用 Add Path to Erlang Search Path? 然后,您将能够在代码中使用它。

        2
  •  1
  •   Sam    7 年前

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

    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

    推荐文章