如何将Erlang程序编译成独立的Windows可执行文件? [英] How do you compile an Erlang program into a standalone windows executable?

查看:606
本文介绍了如何将Erlang程序编译成独立的Windows可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Last.fm的理查德在代谢组织具有。它也是由riak,couchdb等人完成的。他提到提取所需的部件,或将整个VM包括在分发中。主要特点是:该程序不需要Erlang安装在目标机器上。



所以问题是,你如何一步一步,将Erlang程序打包成Windows(而不是重要的linux)可执行文件?



PS我看过SAE项目,我在这里阅读了所有相关的问题。没有回答我的问题。

解决方案


  1. 创建便携版Erlang(例如使用此讨论组的方法: Windows上的Erlang USB )。此练习中最重要的部分是创建具有正确路径的 erl.ini 文件,可用于从任何所需位置启动Erlang。

  2. 创建应用程序和发行版引导脚本的Erlang版本。有关说明,请参阅有关版本的Erlang文档

  3. 创建Windows命令行脚本以引导应用程序。这将简单地以您的引导脚本作为参数(例如 erl -boot someapp )运行Erlang。 Erlang将阅读 erl.ini 文件,以从正确的位置加载您的应用程序和系统库。

  4. 创建一个Windows安装程序相关零件包装在:


    • Erlang发行版

    • erl.ini 文件,其中所有路径作为要由安装应用程序填充的变量

    • 释放应用程序(所有梁文件和引导脚本)

    • 使用引导脚本启动应用程序的命令行脚本


从Windows安装程序的角度来看应该如何工作:




  • 询问用户安装应用程序的位置(或使用一些默认在程序文件中的位置)

  • 将Erlang发行版,应用程序和引导脚本复制到正确的位置

  • 更新 erl .ini 和使用所选位置的命令行脚本

  • 创建图标o r自动启动条目将执行命令行脚本



现在当用户单击图标或以另一种方式执行命令行脚本时实际上从自定义位置运行Erlang,依次Erlang启动脚本启动应用程序。这只是一个一般的想法,因为命令行脚本应该例如在用户第二次启动应用程序时检查Erlang是否还没有运行,或者可能需要卸载它。


Richard of Last.fm over at metabrew has ported his apps to Erlang. It was also done by riak, couchdb and others. He mentions extracting the needed parts, or including the whole VM into the distribution. Main trait here is: the program does not require Erlang to be installed on the target machine.

So the question is, how do you, step by step, package an Erlang program into a windows (and, less important, linux) executable?

P.S. I've seen the SAE project, and I've read all the relevant questions here. None answer my question.

解决方案

  1. Create a portable version of Erlang (for example using method from this discussion group: Erlang on Windows from USB). The most important part in this exercise is the creation of the erl.ini file with correct paths which can be used to start Erlang from any desired location.
  2. Create an Erlang release of your application and the release boot script. For instructions see Erlang documentation about releases.
  3. Create a Windows command line script to boot your application. This will simply run Erlang with your boot script as the parameter (e.g. erl -boot someapp). Erlang will read the erl.ini file to load your application and system libraries from correct locations.
  4. Create a Windows setup application with all the relevant parts packaged in:
    • the Erlang distribution
    • the erl.ini file with all the paths as variables to be filled in by the setup application
    • the release of your application (all the beam files and the boot script)
    • the command line script to boot the application using the boot script

How it should work from the Windows installer point of view:

  • Ask user where to install the application (or use some default location in Program Files)
  • Copy the Erlang distribution, your application and the boot script to the correct location
  • Update erl.ini and the command line script to use the chosen location
  • Create icons or autostart entries that will execute the command line script

Now when user clicks the icon or executes the command line script in another way they will in fact run Erlang from the custom location, which in turn will boot your application according to the Erlang boot script. This is just a general idea because the command line script should for example check if Erlang isn't already running when user starts the application for the second time, or it may need to be able to uninstall it.

这篇关于如何将Erlang程序编译成独立的Windows可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆