如何将Erlang程序编译成独立的Windows可执行文件? [英] How do you compile an Erlang program into a standalone windows executable?
问题描述
所以问题是,你如何一步一步,将Erlang程序打包成Windows(而不是重要的linux)可执行文件?
PS我看过SAE项目,我在这里阅读了所有相关的问题。没有回答我的问题。
- 创建便携版Erlang(例如使用此讨论组的方法: Windows上的Erlang USB )。此练习中最重要的部分是创建具有正确路径的
erl.ini
文件,可用于从任何所需位置启动Erlang。 - 创建应用程序和发行版引导脚本的Erlang版本。有关说明,请参阅有关版本的Erlang文档。
- 创建Windows命令行脚本以引导应用程序。这将简单地以您的引导脚本作为参数(例如
erl -boot someapp
)运行Erlang。 Erlang将阅读erl.ini
文件,以从正确的位置加载您的应用程序和系统库。 - 创建一个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.
- 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. - Create an Erlang release of your application and the release boot script. For instructions see Erlang documentation about releases.
- 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 theerl.ini
file to load your application and system libraries from correct locations. - 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屋!